我正在努力进行计数器重置,重置似乎正在应用,但随后的值似乎会根据重置之前的值增加。
<head>
<style>
ol.list-number2{
text-indent:10px;
}
ol{
list-style-type: decimal;
}
ol > li{
display:inline;
}
/* Set the base count at 0 */
body{
counter-reset:first 1 second 1;
}
/* Reset the count when the start class is available */
ol.list-start-number1:before{ counter-reset: first 0 second 0;}
ol.list-start-number2:before{ counter-reset: second 0; }
/* Prepend the ols with the counter and increment the counter */
.list-number1:before{
content:counter(first) ". ";
counter-increment: first 1;
}
.list-number2:before{
content: "1." counter(second) ". ";
counter-increment: second 1;
}
</style>
</head>
<body>
<div id="magicdomid25" class="ace-line">
<ol class="list-start-number1 list-number1"><li><span class="a9z">test</span></li></ol>
</div>
<div id="magicdomid21231236" class="ace-line">
<ol class="list-start-number2 list-number2"><li><span class="a9z">tesdfsdfsting</span> </li></ol>
</div>
<div id="magicdomid31231230" class="ace-line">
<ol class="list-number2"><li><span class="a9z">tessdfsdftyy</span></li></ol>
</div>
<div id="magicdomid26123" class="ace-line">
<ol class="list-number2"><li><span class="a9z">tessdfsdfting</span></li></ol>
</div>
<div id="magicdomid30" class="ace-line">
<ol class="list-number1"><li><span class="a9z">testyy should be two!</span></li></ol>
</div>
<!-- First list has ended -->
<div id="magicdomid30" class="ace-line">
<span>FEAR ME foo I am the resetter of counters</span>
</div>
<!-- Second list begins -->
<div id="magicdomid25" class="ace-line">
<ol class="list-start-number1 list-number1"><li><span class="a9z">I should be 1</span></li></ol>
</div>
<div id="magicdomid25" class="ace-line">
<ol class="list-start-number2 list-number2"><li><span class="a9z">I should be 1.1</span></li></ol>
</div>
<div id="magicdomid25" class="ace-line">
<ol class="list-number2"><li><span class="a9z"><b>I should be 1.2 but I'm not! :(</b></span></li></ol>
</div>
<div id="magicdomid25" class="ace-line">
<ol class="list-number2"><li><span class="a9z"><b>I should be 1.3 but I'm not! :(</b></span></li></ol>
</div>
<div id="magicdomid25" class="ace-line">
<ol class="list-number1"><li><span class="a9z"><b>I should be 2 but I'm not</b></span></li></ol>
</div>
</body>
小提琴:http: //jsfiddle.net/E8XFK/85/
我想我误解了反继承是如何工作的?
在这里修改 DOM 不是一个选项。