我正在学习计数器和嵌套计数器的使用,参考链接。
以下为我的CSS和HTML代码:
<style>
ol {
counter-reset: my-counter 0;
list-style-type: none;
}
li::before {
content: counters(my-counter, '.');
counter-increment: my-counter;
}
</style>
使用HTML标记
<ol>
<li> First
<ol>
<li> Eleven </li>
<li> Twelve </li>
</ol>
</li>
<li> Second
<ol>
<li> Twenty-one </li>
<li> Twenty-two </li>
</ol>
</li>
</ol>
我如预期地获取到了内容,例如1
和1.1
,但是将before
更改为伪元素marker
,即li::marker
会给出0
和0.0
的值。
但当我只使用这个css时,输出结果与预期相同。
li::marker {content: counters(list-item, '.') ' ';}
我不明白为什么在这个列表中,before和marker伪元素产生了不同的输出。