counter
是否可以根据其值填充数字?
div {
counter-reset: ruler;
}
div > span {
display: block;
line-height: 1rem;
}
div > span::before {
counter-increment: ruler;
content: counter( ruler ) ' ';
}
<div>
<span>Hello, World!</span>
<span>Hello, World!</span>
<span>Hello, World!</span>
<span>Hello, World!</span>
<span>Hello, World!</span>
<span>Hello, World!</span>
<span>Hello, World!</span>
<span>Hello, World!</span>
<span>Hello, World!</span>
<span>Hello, World!</span>
<span>Hello, World!</span>
<span>Hello, World!</span>
<span>Hello, World!</span>
</div>
就像如果有 42 行,数字会像09
or 9
, 420 — 009
or 9
。