Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested css counters with leading zeros

Is it possible to combine the css counters() function with leading zeros, producing a list such as this:

Item 01
  Item 01.01
  Item 01.02
    Item 01.02.01

Leading zeros are possible using content: counter(name, decimal-leading-zero), and combining nested counters is possible using content: counters(name, ".").

I know of workarounds if the level of nesting is known (i.e. I know the list will only ever nest 3 levels deep), but does anyone know if it's possible to combine these for lists of an unknown level of nesting?

like image 822
Jason Avatar asked Jun 07 '12 16:06

Jason


1 Answers

Yes, you can combine these — just supply the counter style as the last argument to counters():

content: counters(name, ".", decimal-leading-zero)
like image 181
BoltClock Avatar answered Nov 15 '22 10:11

BoltClock