我试图掌握CSS计数器的诀窍,但似乎我不能理解它。
下面是我举的一个最小的例子:
<!DOCTYPE html>
<html>
<head>
<style>
body {
counter-reset: chapter;
counter-reset: section;
counter-reset: theorem;
}
.outline-1 {
counter-increment: chapter ;
}
span[class^="section-number"] {
counter-increment: section ;
}
.theorem:before {
counter-increment: theorem;
content: "Theorem " counter(chapter) "." counter(section) "." counter(theorem) ": ";
}
</style>
</head>
<body>
<div id="outline-container-sec-1-2" class="outline-1">
<h3 id="sec-1-2"><span class="section-number-1">1.2</span> Basic</h3>
<div class="theorem"> Very important theorem! </div></div>
<div id="outline-container-sec-1-2" class="outline-1">
<h3 id="sec-1-2"><span class="section-number-2">1.2</span> Some Combinatorics</h3>
<div class="theorem"> Very important theorem! </div></div>
</body>
</html>我得到的结果是:
1.1基础版
定理1.0.1:非常重要的定理!
1.2一些组合学
定理2.0.2:非常重要的定理!
为什么第二个计数器保持在0?为什么我可以计算span元素?
https://stackoverflow.com/questions/41419927
复制相似问题