[英]Insert vertical spacing between list items
I have a simple list and I would like to add a border-bottom as the below image shows.我有一个简单的列表,我想添加一个底部边框,如下图所示。
My solution我的解决方案
li { height: 48px; border-bottom: 1px solid #D0D0D0; } li::before { content: counter(li); background: #29C9CE; display: inline-block; width: 1em; font-family: Raleway; font-style: normal; font-weight: bold; font-size: 32px; line-height: 38px; text-align: center; margin-right: 5px; color: #FFFFFF; }
<ol> <li>full border bottom width</li> <li>full border bottom width</li> <li>full border bottom width</li> </ol>
I tried even tried with after pseudo-element but nothing,我什至尝试过使用伪元素但没有,
I want the result to be the same as the image above.我希望结果与上图相同。 thanks谢谢
You can add some top and bottom margin
to each <li>
element.您可以为每个<li>
元素添加一些顶部和底部margin
。 Also, your counter()
usage needed to be updated so I added counter-increment: listCounter
to the <li>
elements and then used counter(listCounter)
for the pseudo element li::before
content.此外,您的counter()
使用需要更新,因此我将counter-increment: listCounter
添加到<li>
元素,然后将counter(listCounter)
用于伪元素li::before
内容。 Try this out.试试这个。
li { height: 48px; border-bottom: 1px solid #D0D0D0; margin-bottom: .75rem; display: flex; align-items: flex-start; /* change this to center for text to be aligned with list number */ counter-increment: listCounter; } li:not(li:first-child) { margin-top: .75rem; } li::before { content: counter(listCounter); background: #29C9CE; display: inline-block; width: 1em; font-family: Raleway; font-style: normal; font-weight: bold; font-size: 32px; line-height: 38px; text-align: center; margin-right: 5px; color: #FFFFFF; }
<ol> <li>full border bottom width</li> <li>full border bottom width</li> <li>full border bottom width</li> </ol>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.