列表的Css计数器

时间:2014-04-24 11:03:15

标签: html css

我正在尝试在我的有序列表中使用css中的计数器增量,但它不起作用

这就是我要显示的内容:

1. Acknowledgements
   1.1 blah, blah ....
   1.2 blah, blah ....
   1.3 blah, blah ....

2. Risk Statement
   2.1 blah, blah ....
   2.2 blah, blah ....
   2.3 blah, blah ....

3. License
   3.1 blah, blah ....
   3.2 blah, blah ....
   3.3 blah, blah ....

但这就是发生的事情...... http://jsfiddle.net/XQKcy/

1 个答案:

答案 0 :(得分:8)

Demo Fiddle

你非常接近:

body {
    counter-reset: listCounter;
}
ol {
    counter-increment: listCounter;
    counter-reset: itemCounter;
    list-style:none;
}
li{
    counter-increment: itemCounter;
}
li:before {
    content: counter(listCounter) "." counter(itemCounter);
    left:10px;
    position:absolute;
}