Page 1 of 1

CSS Counter

Posted: Mon May 09, 2011 12:14 pm
by patrick
Hi,

I have an XML which should have auto-numbered sections in the author view. The root element han an Attribut "startnum" which pretend the initial value of the first section.

Code: Select all


<document startnum="5">
<section/> <!-- Should have "5" as number -->
<section/> <!-- 6 -->
<section/> <!-- 7 ... -->
</document>
I've found no way to use the attribute value as a variable in css, e.g.:

Code: Select all


document[startnum] {
counter-reset: sect1 attr(startnum)-1;
}
The only workaround I've found is to define the start value for each possible startnum value:

Code: Select all

document[startnum="2"] {
counter-reset: sect1 1;
}
document[startnum="3"] {
counter-reset: sect1 2;
}
document[startnum="4"] {
counter-reset: sect1 3;
}
document[startnum="5"] {
counter-reset: sect1 4;
}
document[startnum="6"] {
counter-reset: sect1 5;
}
document[startnum="7"] {
counter-reset: sect1 6;
}
document[startnum="8"] {
counter-reset: sect1 7;
}
document[startnum="9"] {
counter-reset: sect1 8;
}
document[startnum="10"] {
counter-reset: sect1 9;
}
Is it possible to support a better solution for this cases?

Re: CSS Counter

Posted: Mon May 09, 2011 2:31 pm
by Radu
Hi Patrick,

Unfortunately for now we do not have support for evaluating functions in the "counter-reset" values. I added an improvement request for this.
We also have plans to add functions for simple arithmetic evaluations (like adding that "1" in your case).
I'll update this post when the request gets implemented.

Regards,
Radu

Re: CSS Counter

Posted: Mon May 09, 2011 4:56 pm
by patrick
Hi Radu,

Thanks!