I am using a self-styled, numbered list. How can I read the start-attribute and add it to the counter with CSS?
HTML
- Number
ol[start="10"] {
counter-reset: lis 9;
}
Demo , but this will only apply for this ol attribute. You would need some javaScript in order to retrieve attribute value to apply, generate the correct counter-reset.
see this : DEMO to generate 100 rules from these lines :
@for $i from 1 through 100 {
.ol[start="#{$i}"] {
counter-reset: lis $i ;
}
}
Then just copy paste the rules generated if Scss is not avalaible on your hosting .
:
$( "ol" ).each(function() {
var val=1;
if ( $(this).attr("start")){
val = $(this).attr("start");
}
val=val-1;
val= 'lis '+ val;
$(this ).css('counter-increment',val );
});
Notice that : $(this ).css('counter-reset',val ); works too :)
.