【发布时间】:2019-07-30 22:01:51
【问题描述】:
我正在尝试写一本电子书,但在管理章节/章节/小节的计数器方面遇到了问题。
body {
counter-reset: chapter;
counter-reset: section;
counter-reset: subsection;
}
h1.chapter::before {
counter-reset: section;
counter-reset: subsection;
counter-increment: chapter;
content: "Chapter " counter(chapter) ": ";
}
h2.section::before {
counter-reset: subsection;
counter-increment: section;
content: "Section " counter(chapter) "." counter(section) ": ";
}
h3.subsection::before {
counter-increment: subsection;
content: "Subsection " counter(chapter) "." counter(section) "." counter(subsection) ": ";
}
<h1 class="chapter"> The first chapter</h1>
<h2 class="section"> The first section </h2>
<h2 class="section"> The second section </h2>
<h3 class="subsection"> The first subsection </h3>
<h3 class="subsection"> The second subsection </h3>
<h1 class="chapter"> The second chapter</h1>
<h2 class="section"> The second chapter's first section</h2>
<h3 class="subsection"> The second chapter's first subsection </h3>
这就是显示的内容:
所以我不知道为什么 chapter 和 section 只是不坚持而 `subsection' 不重置...
【问题讨论】:
标签: html css css-counter