I'm trying to target a class element (appearing more than once in the DOM) by its index or iteration, strictly using CSS.
I know of several different ways of achieving this: I could toss the element(s) in an array and retrieve a specific index of said element (Javascript). I could label the element I'm trying to target with an #ID. I could refine the targeted element by specifying an attribute (.element[href="link"]
). The pseudo-class :first-child
and :last-child
only target the children of that (parent) element (Duh!).
Example: I have a .class
appearing 5 times within my DOM and I want to affect the CSS properties of the 3rd iteration of that .class
element.
I wish there was a pseudo-class of .element:index-3.
There's probably something out there that let's you do just that.