I wondered if there is a better solution than what I found without changing the html structure
The HTML structure looks like this:
<div class="wrap"> <div class="divider"></div> <div class="block"></div> <div class="block"></div> <div class="divider"></div> </div>
So the different DIVs on the same level, what I want to do is color every fourth block differently until a separator appears, then it will have to recount.
I thought something like .block:nth-child(4n) would do the trick, but in fact it takes into account elements based on the parent, and not based on the class.
Here's a JSFiddle to try. Lock No. 4 and No. 8 in each line should be different http://jsfiddle.net/SKgdH/3/
And here is how I did this work: http://jsfiddle.net/SKgdH/1/
What I did was find the fourth brother of this delicator .divider + .block + .block + .block + .block
This works, however, I have to write the same for block 8, 12, 16, .., which no longer makes it automatic.
Is there something like .divider + .block:nth-sibling(4) or .divider + .block:nth-of-class(4) ?
Perhaps you have an idea on how to solve this problem without changing the source code or using javascript.
css css-selectors
user828591
source share