不知道描述问题的正确方法,所以这里是一个JSFiddle。
这里的问题是编号为Para 1.3
andPara 1.4
是关闭的:当计数器“离开”嵌套标记para
的范围时,它不会“重置” 。<section>
body { counter-reset: chapter 0; }
section { counter-reset: para 0; }
h2:before {
counter-increment: chapter;
content: counter(chapter) ". ";
}
section p:before {
counter-increment: para;
content: counter(chapter) "." counters(para, ".") ". ";
}
<h2>Chapter 1</h2>
<section>
<p>Para 1.1</p>
<p>Para 1.2</p>
<section>
<p>Para 1.2.1</p>
<p>Para 1.2.2</p>
<section>
<p>Para 1.2.2.1</p>
<p>Para 1.2.2.2</p>
</section>
</section>
<p>Para 1.3</p>
<p>Para 1.4</p>
</section>