Re: [CSS21] Possible counters() limitation?

I’m using this for my XHTML2:

section:first-of-type {
    counter-reset: section-num 0;
}
section {
    counter-increment: section-num;
}
section h:not(:first-of-type) {
    /* if section has two h children, increase section number for second 
h */
    counter-increment: section-num;
}
section section h::before {
    content: counters(section-num,".") " ";
}


~Grauw

Anne van Kesteren schreef:
> Hi,
>
> It seems that the counters() construct doesn't really address the use 
> case of sections and headers. With a structure such as:
>
>   <section>
>    <h>LEVEL 1</h>
>    <section>
>     <h>LEVEL 2</h>
>    </section>
>    <section>
>     <h>LEVEL 2</h>
>    </section>
>   </section>
>
> ... I can't really find the a way to get an outline such as:
>
>   1.  LEVEL 1
>   1.1 LEVEL 2
>   1.2 LEVEL 2
>
> I attached an example of this so people can play with it and try to 
> make it work. I hope it makes it through.
>
> Kind regards,
>
>
> --Anne van Kesteren
> <http://annevankesteren.nl/>
> <http://www.opera.com/>
> ------------------------------------------------------------------------
>
> <html xmlns="http://www.w3.org/1999/xhtml">
>  <head>
>   <title>counters() playground</title>
>   <style>
>    section, h { display:block }
>    section { margin:1em 0 1em 2em; counter-reset:item; counter-increment:item }
>    h::before { content:counters(item, ".") ". " }
>   </style>
>  </head>
>  <body>
>   <section xmlns="http://ns.example.org/200609#test">
>    <h>LEVEL 1</h>
>    <section>
>     <h>LEVEL 2</h>
>     <section>
>      <h>LEVEL 3</h>
>      <section>
>       <h>LEVEL 4</h>
>      </section>
>      <section>
>       <h>LEVEL 4</h>
>      </section>
>     </section>
>    </section>
>   </section>
>  </body>
> </html>
>   


-- 
Ushiko-san! Kimi wa doushite, Ushiko-san nan da!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Laurens Holst, student, university of Utrecht, the Netherlands.
Website: www.grauw.nl. Backbase employee; www.backbase.com.

Received on Tuesday, 12 September 2006 09:53:10 UTC