HTML 順序付きリスト 1.1、1.2 (ネストされたカウンターとスコープ) が機能しない 質問する

HTML 順序付きリスト 1.1、1.2 (ネストされたカウンターとスコープ) が機能しない 質問する

ネストされたカウンターとスコープを使用して順序付きリストを作成します。

ol {
    counter-reset: item;
    padding-left: 10px;
}
li {
    display: block
}
li:before {
    content: counters(item, ".") " ";
    counter-increment: item
}
<ol>
    <li>one</li>
    <li>two</li>
    <ol>
        <li>two.one</li>
        <li>two.two</li>
        <li>two.three</li>
    </ol>
    <li>three</li>
    <ol>
        <li>three.one</li>
        <li>three.two</li>
        <ol>
            <li>three.two.one</li>
            <li>three.two.two</li>
        </ol>
    </ol>
    <li>four</li>
</ol>

次のような結果が期待されます。

1. one
2. two
  2.1. two.one
  2.2. two.two
  2.3. two.three
3. three
  3.1 three.one
  3.2 three.two
    3.2.1 three.two.one
    3.2.2 three.two.two
4. four

代わりに、これが私が見ているものです(番号が間違っています):

1. one
2. two
  2.1. two.one
  2.2. two.two
  2.3. two.three
2.4 three <!-- this is where it goes wrong, when going back to the parent -->
  2.1 three.one
  2.2 three.two
    2.2.1 three.two.one
    2.2.2 three.two.two
2.3 four

全く分かりません。どこが間違っているのか分かる人はいますか?

ここに JSFiddle があります:http://jsfiddle.net/qGCUk/2/

ベストアンサー1

「CSSを正規化する」のチェックを外す -http://jsfiddle.net/qGCUk/3/ここで使用されるCSSリセットは、すべてのリストのマージンとパディングを0にデフォルト設定します。

アップデート http://jsfiddle.net/qGCUk/4/- メインリストにサブリストを含める必要があります<li>

ol {
  counter-reset: item
}
li {
  display: block
}
li:before {
  content: counters(item, ".") " ";
  counter-increment: item
}
<ol>
  <li>one</li>
  <li>two
    <ol>
      <li>two.one</li>
      <li>two.two</li>
      <li>two.three</li>
    </ol>
  </li>
  <li>three
    <ol>
      <li>three.one</li>
      <li>three.two
        <ol>
          <li>three.two.one</li>
          <li>three.two.two</li>
        </ol>
      </li>
    </ol>
  </li>
  <li>four</li>
</ol>

おすすめ記事