1

是否可以在有序列表前面加上英镑符号或哈希符号?

像这样:

#1. something
#2. something else
#3. another thing
...
4

2 回答 2

5

这是遵循此答案建议的提示的解决方案:

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 会遇到这个问题。

于 2013-02-04T17:43:43.093 回答
0

CSS

.hash-counter {
    counter-reset:hash;
    list-style-type: none;
}

.hash-counter > li:before {
    counter-increment:hash;
    content:"#" counter(hash) ". ";
}

但它可能会导致一些其他问题。

于 2013-02-04T17:42:08.300 回答