I am only looking for a CSS method (without JS) to ignore hidden elements in nth-child counts. Is it possible?
I have this HTML:
<div class="gallery-item"><img src="http://placehold.it/150x150"></div> <div class="gallery-item"><img src="http://placehold.it/150x150"></div> <div class="gallery-item empty"></div> <div class="gallery-item"><img src="http://placehold.it/150x150"></div> <div class="gallery-item empty"></div> <div class="gallery-item"><img src="http://placehold.it/150x150"></div> <div class="gallery-item"><img src="http://placehold.it/150x150"></div>
I am trying to target every second element of the gallery, which is not empty, but this does not work:
.gallery-item:not(.empty):nth-child(2n) {}
I do not want to use JS because it is a complex site with many breakpoints, and I do not want to add onresize listeners for something so basic.
source share