gpt4 book ai didi

html - 你能设置有序列表编号的样式吗?

转载 作者:技术小花猫 更新时间:2023-10-29 11:30:52 26 4
gpt4 key购买 nike

我正在尝试为有序列表中的数字设置样式,我想添加背景颜色、边框半径和颜色,以便它们与我正在使用的设计相匹配:

enter image description here

我想这是不可能的,我必须为每个数字使用不同的图像,即

ol li:first-child {list-style-image:url('1.png')};
ol li:nth-child(2) {list-style-image:url('2.png');}
etc...

有没有更简单的解决方案?

最佳答案

您可以使用 CSS counters 执行此操作,结合 :before 伪元素:

 ol {
list-style: none;
counter-reset: item;
}
li {
counter-increment: item;
margin-bottom: 5px;
}
li:before {
margin-right: 10px;
content: counter(item);
background: lightblue;
border-radius: 100%;
color: white;
width: 1.2em;
text-align: center;
display: inline-block;
}
<ol>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ol>

关于html - 你能设置有序列表编号的样式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23610151/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com