简体   繁体   English

列表中元素之间的垂直间距

[英]Vertical spacing between elements in a list

I have a list of elements which are in a row. 我有一个连续的元素列表。 However, because there are too many lists to fit in the container, some of them go on a second line. 但是,由于容器中的列表太多,因此其中一些在第二行。

How do I add extra spacing between the first and second line of these elements, considering the elements already have margins set? 考虑到元素已经设置了边距,如何在这些元素的第一行和第二行之间添加额外的间距?

在此处输入图片说明

I want there to be more spacing between the first line of "Tests" and the second line of "Tests". 我希望在“测试”的第一行和“测试”的第二行之间有更多的间距。 I don't want the spacing above or under the two lines to change, just in between. 我不希望这两行之间的间距改变。 I'm figuring it has something to do with adjacent sibling selectors? 我在想这与相邻的兄弟选择器有关吗?

Give the following CSS: 提供以下CSS:

ul {line-height: 2; vertical-align: top;}

This CSS will not cause spacing above the line. 该CSS不会在行上方引起间距。

Snippet 片段

 ul {display: block; width: 200px; list-style: none; margin: 0; padding: 0; border: 1px solid #ccc; vertical-align: top;} ul li {display: inline-block; width: 40px; line-height: 1; vertical-align: top;} ul {line-height: 2; vertical-align: top;} 
 <ul> <li>Test</li> <li>Test</li> <li>Test</li> <li>Test</li> <li>Test</li> <li>Test</li> </ul> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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