繁体   English   中英

排序列表编号和内容的不同样式

[英]Different style for ordered list number and content

是否有可能使有序列表的数字(或字母或数字等)与内容具有不同的样式,而在每个列表元素内部没有某种div或span标签?

可以将列表样式设置为“ 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 */
}

是的,您可以这样:

li {
  list-style: none;
  counter-increment: myCounter;
}
li:before {
    content: counter(myCounter);
    font-size: 19px;
    color: red;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM