przewiń do treści

HTML, XHTML i CSS. Praktyczne projekty. Wydanie II

Włodzimierz Gajda

body {
    counter-reset: h1;
}
h1 {
    counter-reset: h2;
}
h1:before {
    content: counter(h1) ". ";
    counter-increment: h1;
}
h2 {
    counter-reset: h3;
}
h2:before {
    content: counter(h1) "." counter(h2) ". ";
    counter-increment: h2;
}
h3 {
    counter-reset: h4;
}
h3:before {
    content: counter(h1) "." counter(h2) "." counter(h3) ". ";
    counter-increment: h3;
}

<h1>Lorem ipsum</h1>
<h2>Dolor sit amet</h2>
<h2>Duis sapien</h2>
<h1>Pellentesque viverra</h1>
<h1>Curabitur non turpis</h1>
<h2>Lorem</h2>
<h3>Ipsum</h3>
<h3>Dolor</h3>
<h3>Sit</h3>
<h3>Amet</h3>

Listing 38.2. Wielopoziomowa automatyczna numeracja

Rozdział 38. Uzupełnienie wiadomości na temat CSS

listing-38-02.txt