I'm looking for an nth-of-type descendant selector.
I have a class .class-name present a total of 7 times in my DOM tree.
How do I select the 3rd iteration or 4th iteration of the said class?
(the said class has different elements as parents (with different classes applied to them)
I tried this code and it doesn't work: (because nth-of-type refers to the direct parent and I want it to work for the BODY element, which is an ancestor)
.class-name:nth-of-type(3) {margin-top: -215px;}
.class-name:nth-of-type(4) {margin-top: 34px;}
.class-name:nth-of-type(5) {margin-top: -115px;}
.class-name:nth-of-type(6) {margin-top: 455px;}
.class-name:nth-of-type(7) {margin-top: 545px;}
(The whole reason for using the said class was to be able to select the N-th iteration of it throughout the DOM tree, to avoid the hastle of targeting each ancestor using more complicated selector rules)
P.S. This is a more clear example than the issue posted here (Can I combine :nth-child() or :nth-of-type() with an arbitrary selector?). It's related, but not a duplicate.