Html 项目符号列表行之间的间距

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15665505/
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 06:55:49  来源:igfitidea点击:

Spacing between bullet list rows

htmlcss

提问by iefpw

How do I set the spacing between bullet lists?

如何设置项目符号列表之间的间距?

  • asdfasdf
  • asdf23223
  • 自卫队
  • asdf23223

I want to put a little more space between the first and second rows like

我想在第一行和第二行之间多留一点空间,比如

<ul>
    <li>asdfasdf</li>
<p />
    <li>asdf23223</li>
</ul>

回答by mattytommo

Add topand bottompadding to the lis, like so:

添加topbottom填充到lis,如下所示:

ul li { padding: 5px 0px; }

And take out that crazy looking <p />tag.

取出那个看起来很疯狂的<p />标签

Demo: http://jsfiddle.net/aFED2/

演示:http: //jsfiddle.net/aFED2/

回答by Floremin

I'm assuming <p />tag is just a typo, it shouldn't be there ;)

我假设<p />标签只是一个错字,它不应该在那里;)

Add this into your <head>tag:

将此添加到您的<head>标签中:

<style>
    ul li { margin-bottom: 10px; }
</style>

回答by Mike Schwartz

You might be able to do something like this:

你也许可以做这样的事情:

<ul style="line-height:1.4;">

回答by gaynorvader

Use line-heightThis will put spacing above and below the text.

使用line-height这将在文本上方和下方放置间距。

回答by Hassaan

Use the CSS as:

使用 CSS 为:

li { padding: 10px 0px 0px; }
li:first-child { margin-bottom: 0px; }

回答by Heidi

I just use the so that it will not mess with the styles of all of my other pages when using html and php.

我只是使用 ,以便在使用 html 和 php 时不会干扰我所有其他页面的样式。

回答by ellipsis

You can use the pretag. No need for the css

您可以使用pre标签。不需要css

<ul>
  <pre>
    <li>Foo</li>
    <li>Bar</li>
    <li>Baz</li>
    </pre>
</ul>

回答by Eli

You can just add a margin-bottomfor your list item

您只需margin-bottom为列表项添加一个

Demo: http://jsfiddle.net/6tcpd/

演示:http: //jsfiddle.net/6tcpd/