是否可以使有序列表的数字(或字母或数字等)具有与内容不同的样式而不在每个列表元素中包含某种div或span标记?
答案 0 :(得分:3)
将list-style设置为'none'并用CSS计数器和伪元素替换默认编号是可能的。示例:http://jsbin.com/agagoc/1/edit
ol {
list-style: none;
counter-reset: my-awesome-counter;
}
li {
counter-increment: my-awesome-counter;
}
li:before {
content: counter(my-awesome-counter);
/* any style for numbers, as if they were spans before the content of LIs, goes here */
}
答案 1 :(得分:2)
是的,你可以like this:
li {
list-style: none;
counter-increment: myCounter;
}
li:before {
content: counter(myCounter);
font-size: 19px;
color: red;
}