I have the following code:
<ul class="list">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
I've styled this list with grey stripes:
.list li:nth-child(2n) {
background-color: #ccc;
}
Works great, but then I hide some of the li
elements and the order of the stripes breaks. Fiddle
I've tried updating the selector with :not()
:
.list li:not(.hidden):nth-child(2n) {
background-color: #ccc;
}
But this was useless.
Could anyone advice how to order pseudo classes to keep stripes order?