出于样式的原因,我使用带有伪类的 ol 元素。不幸的是,我无法开始计算所需索引中的列表项。怎么了?
HTML
<ol start="14">
<li>car</li>
<li>flower</li>
<li>garden</li>
<li>shool</li>
<li>river</li>
</ol>
CSS
ol {
width: 850px;
padding: 0;
margin: 0 auto;
counter-reset: item;
list-style-type: none;
font-size: 18px;
line-height: 23px;
font-weight: 400;
font-style: normal;
}
li:before {
content: counter(item)" ";
counter-increment: item;
}
最佳答案
可以在counter-reset
中指定起始值:
counter-reset: item 13;
不幸的是,当前的浏览器不支持访问属性值,所以像 counter-reset: item calc(attr(start) - 1);
这样的东西是行不通的。您必须明确设置该值。
关于html - ol 无法从特定计数开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27818667/