我有一个带有两个不同计数器的<ul>-列表:

ul.numbered {
    counter-reset: alphaCounter, numberCounter;
}

ul.numbered li.numbered,
ul.numbered li.lettered {
    padding-left: 1.8em;
}

ul.numbered li.numbered:before {
    position: absolute;
    top: 0;
    left: 0;
    counter-increment: numberCounter;
    content: counter(numberCounter, decimal) ". ";
}

ul.numbered li.lettered:before {
    position: absolute;
    top: 0;
    left: 0;
    counter-increment: alphaCounter;
    content: counter(alphaCounter, upper-alpha) ". ";
}


此列表以A.,B。等正确计数li.lettered项。但是li.numbered项始终以“ 1”开头。如果将计数器重置的顺序切换为counter-reset: numberCounter, alphaCounter;,则数字将正确计数,并且字母始终以“ A”开头。

从我所阅读的内容中,我可以正确地设置列表,但显然没有。有什么帮助吗?

最佳答案

好的,问题是counter-reset上两个计数器之间的逗号。在这种情况下,重置多个计数器的正确解决方案是:

counter-reset: numberCounter alphaCounter;


W3C, 12.4 Automatic counters and numbering

10-05 21:47