我有这个清单:
<ol start="0"> <li>Tokyo Skytree</li> <li>Canton Tower</li> <li>CN Tower</li> <li>Ostankino Tower</li> <li>Oriental Pearl Tower</li> </ol>
1. Tokyo Skytree 2. Canton Tower 3. CN Tower 4. Ostankino Tower 5. Oriental Pearl Tower
现在我想要的是这样的东西:
[1] Tokyo Skytree [2] Canton Tower [3] CN Tower [4] Ostankino Tower [5] Oriental Pearl Tower
理想情况下,我想要一个基于0的数组,如:
[0] = Tokyo Skytree [1] = Canton Tower [2] = CN Tower [3] = Ostankino Tower [4] = Oriental Pearl Tower
我已经阅读了关于CSS Numbering Style和CSS Lists W3C Draft但我无法找到有效的解决方案.
解决方法
你可以这样做:
ol { counter-reset: o-counter -1; list-style-type: none; } ol li:before { content: '[' counter(o-counter) '] = '; counter-increment: o-counter; }
http://jsfiddle.net/userdude/Fb3ab/2/
请记住,o计数器(或任何你称之为的计数器)需要在父UL / OL上才能递增.并且,IE7也不支持这一点.
更多信息:
> http://www.w3.org/TR/CSS21/generate.html#counters
> http://css-infos.net/property/content