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 に答える