番号付きリストの先頭にポンド記号またはハッシュ記号を追加することはできますか?
このような:
#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) ". ";
}
しかし、それは他の問題を引き起こす可能性があります。