是否可以在有序列表前面加上英镑符号或哈希符号?
像这样:
#1. something
#2. something else
#3. another thing
...
HTML:
<ol class="custom">
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
CSS:
ol.custom {
list-style-type: none;
margin-left: 0;
}
ol.custom > li {
counter-increment: customlistcounter;
}
ol.custom > li:before {
content: "#" counter(customlistcounter);
font-weight: bold;
float: left;
width: 3em;
}
ol.custom:first-child {
counter-reset: customlistcounter;
}
“自定义”类名只是可以恢复到原始行为;如果你把它拿出来,这将适用于所有ol
使用这个样式表的标签。注意使用伪选择器引入的限制:before
:IE6 和 IE7 会遇到这个问题。
CSS
.hash-counter {
counter-reset:hash;
list-style-type: none;
}
.hash-counter > li:before {
counter-increment:hash;
content:"#" counter(hash) ". ";
}
但它可能会导致一些其他问题。