是否可以将特定样式应用于<ol>
列表的数字?
例子:
- 富
- 酒吧
我需要“1”。和“2”。为红色,“foo”和“bar”为蓝色。
使用before
伪元素和counter
函数可以实现:http: //jsfiddle.net/QXe7K/
ul { counter-reset : item; }
li { color : blue; }
li:before {
counter-increment : item;
content : counter(item) ". ";
color : red;
}
不需要额外的标记。它也适用于 IE8(以及其他所有现代浏览器)