简体   繁体   中英

Can't border the way I want because of padding

Here's what's happening : 结果

code :(Html)

<ul class="menu"  style="
    margin-top: 0px;
    margin-bottom: 0px;">
    <li>Home</li>
    <li>News</li>
    <li>Contact</li>
    <li>About</li>
</ul>

code:(Css)

.menu {

list-style-type: none;

background-color: #B7FFED;

font-size: 70px;

display: inline-block;

font-family: 'Lilita One', cursive;

padding: 0px;

height: 1000px;

}



.menu li{  

padding-bottom: 100px;    
padding-top: 10px;
border: 2px solid;

}

I want this to be able to only border the words but to not have huge gaps. Here is a picture of what I want: 我想要的东西

You need to use margin instead of padding and add overflow: hidden , so that your margins do not collapse:

 .menu { list-style-type: none; background-color: #B7FFED; font-size: 70px; display: inline-block; font-family: 'Lilita One', cursive; padding: 0px; height: 1000px; overflow: hidden; margin: 0; } .menu li { margin-bottom: 100px; margin-top: 10px; border: 2px solid; }
 <ul class="menu"> <li>Home</li> <li>News</li> <li>Contact</li> <li>About</li> </ul>

我只需要将填充更改为边距即可实现..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM