sea*_*sTL 2 html css background-color html-lists
我有一个有序列表 (a, b, c...) 并且想要使实际项目符号 (a, b, c...) 的背景颜色不同。我将如何设计这个?list-type 属性似乎只改变了项目符号,而不是给它们添加样式。我想保持列表的 type="a" 结构,并简单地为每个字母添加背景颜色。
另外......有人可以与我分享如何将子弹居中或将它们冲洗到一侧吗?目前,他们看起来有点不合时宜。
使用上面@kingkong 的评论,您可以执行以下操作:
ul > li:before {
background-color: red;
margin-right: 5px;
padding: 0 5px;
content: counter(index, lower-alpha);
counter-increment:index;
}
li:first-child {
counter-reset:index;
}
ul li {
list-style: none;
}
Run Code Online (Sandbox Code Playgroud)
这是一个小提琴:http : //jsfiddle.net/2ZsQY/