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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 21:17:26  来源:igfitidea点击:

Remove Spacing between li

css

提问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 litags 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-heighton the ulelement. It's possible I didn't get the full question because the original link is now broken, but generally, line-heightmight be the way to go

奇怪的是没有人提到line-height这个ul元素。可能我没有得到完整的问题,因为原始链接现在已损坏,但一般来说,line-height可能是要走的路

回答by rflmyk

Do you want using list center, you can using:

你想使用列表中心,你可以使用:

 ul { text-align: center; }
 li { margin-right: -4px; }

How on this link

这个链接怎么样