중첩 된 카운터와 범위를 사용하여 정렬 된 목록을 만듭니다.
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.
>1.1.
1.2.
1.3.
등등?