CSS 我如何在我的 ul 的 li 之间添加空格(margin-bottom)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21327154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do i add space(margin-bottom ) between the li's of my ul?
提问by vijar
Hi i am trying to add some space below each li of my ul. When i try to set margin-bottom on the li it does not work it just adds margin above the first li element of the list. Can someone tell me how i can add a space(margin) bellow each li
嗨,我正在尝试在我的 ul 的每个 li 下方添加一些空间。当我尝试在 li 上设置 margin-bottom 时,它不起作用,它只是在列表的第一个 li 元素上方添加边距。有人可以告诉我如何在每个 li 下方添加一个空格(边距)
回答by Vivek
ul li{margin-bottom:10px;}
You can check the example here: http://jsfiddle.net/gdfxk/
您可以在此处查看示例:http: //jsfiddle.net/gdfxk/
回答by dooxe
I have just tried that:
我刚刚试过:
And it seems to work.
它似乎有效。
Html :
网址:
<ul class="ul1">
<li>Toto</li>
<li>Titi</li>
<li>Tata</li>
</ul>
<ul class="ul2">
<li>Toto</li>
<li>Titi</li>
<li>Tata</li>
</ul>
<ul class="ul3">
<li>Toto</li>
<li>Titi</li>
<li>Tata</li>
</ul>
CSS :
CSS :
li
{
background-color : gray;
height : 25px;
}
.ul1>li
{
margin-bottom : 0px;
}
.ul2>li
{
margin-bottom : 5px;
}
.ul3>li
{
margin-bottom : 5px;
}