CSS 删除 li 之间的间距
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1770601/
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
Remove Spacing between li
提问by Zach Smith
How can I remove spacing between the li found here?
如何删除此处找到的 li 之间的间距?
http://blog.raveis.com/badge/b.html
http://blog.raveis.com/badge/b.html
Confused on how to do this and I don't want to use negative margins. any help would be greatly appreciated.
对如何做到这一点感到困惑,我不想使用负边距。任何帮助将不胜感激。
回答by Josh Stodola
Make your li
tags display:block;
and float:left;
(instead of display:inline;
)
制作您的li
标签display:block;
和float:left;
(而不是display:inline;
)
回答by tsu1980
Try this.
尝试这个。
ul { font-size: 0; }
回答by xael
This is rediculously late in the piece but I had the same problem today.
这件作品的后期可笑,但我今天遇到了同样的问题。
I fixed it by laying out my HTML like so, thereby removing any space between the list it:
我通过像这样布置我的 HTML 来修复它,从而删除列表之间的任何空格:
<li>
list-item 1
</li><li>
list-item 2
</li><li>
list-item 3
</li>
Example on Code Pen
代码笔示例
回答by goonerify
Surprised that no one mentioned line-height
on the ul
element. It's possible I didn't get the full question because the original link is now broken, but generally, line-height
might be the way to go
奇怪的是没有人提到line-height
这个ul
元素。可能我没有得到完整的问题,因为原始链接现在已损坏,但一般来说,line-height
可能是要走的路