如何在有序列表中左对齐数字?
1. an item
// skip some items for brevity
9. another item
10. notice the 1 is under the 9, and the item contents also line up
Run Code Online (Sandbox Code Playgroud)
更改有序列表中的数字后面的字符?
1) an item
Run Code Online (Sandbox Code Playgroud)
还有一个CSS解决方案,可以从数字更改为字母/罗马列表,而不是使用ol元素上的type属性.
我最感兴趣的是适用于Firefox 3的答案.
出于样式的原因,我使用带有伪类的ol元素.不幸的是,我无法从所需的索引开始计算列表项.怎么了?
HTML
<ol start="14">
<li>car</li>
<li>flower</li>
<li>garden</li>
<li>shool</li>
<li>river</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
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;
}
Run Code Online (Sandbox Code Playgroud)