CSS中的计数器增量 [英] counter-increment in CSS

查看:99
本文介绍了CSS中的计数器增量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得一个有序列表第一个项目不应该以数字开头。该数字应从第二个项目开始。

I am trying to get an ordered list first item shouldn't start with number. The number should start from second item.

请检查此网址我要实现的内容 - http://jsfiddle.net/kheema/tXtQF/5/

please check this URL what I am trying to achieve-- http://jsfiddle.net/kheema/tXtQF/5/

这里使用计数器复位和计数器增量第一项显示0,第二项从1开始..如果我能删除0我的问题将解决。

here using counter-reset and counter-increment first item shows 0 and second item starts from 1.. and if anyhow I could remove a 0 my problem will solve.

有人有一个更好的想法

推荐答案

只是为了解决这个问题吗?

解决方案

将最后一个css规则更改为

just change last css rule into

ol li:before {content: ""; color: green; display: inline-block; width: ... ; }
ol li + li:before {content: counter(chapter) "."; }

这样您就可以插入从 li 元素(我使用 li + li ,所以它也可以用于 IE8

in this way you insert the content starting from second li element (I used li + li so it can work also with IE8)

请参阅小提琴: http://jsfiddle.net/WwNqN/

这篇关于CSS中的计数器增量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆