Set Child count + index of child with custom properties
Would like your opinions,
Because i like to play with the styling of an element based on it's index within a parent (and to be able to calculate with it) , normally i would setup custom properties manually with the nth-child selector or as inline style within the html element.
Unfortunately CSS is not able (yet) to do it on it's own.
I was thinking of doing it programmatically (JS) on page load and with an observer to keep it up to date.
What do you think of this approach?
example: https://codepen.io/MarkBoots/pen/MWNXaNm
0 Replies