I have the following scenario:
HTML:
<div class='linha visivel'>Visivel</div>
<div class='linha visivel'>Visivel</div>
<div class='linha oculto' style='display:none'>Invisivel</div>
<div class='linha visivel'>Visivel</div>
CSS:
.visivel:nth-child(odd) { background: yellow }
.visivel:nth-child(even) { background: green }
Results found:
- 1stlinewithvisibleclassYELLOW
- 2ndlinewithvisibleclassGREEN
- 3rdlinewithvisibleclassGREEN
Expectedresult:
- 1st line with visible class YELLOW
- 2nd line with visible class GREEN
- 3rd line with visible class YELLOW
From what I understand, nth-child should alternately paint the divs with the visible class. But as there is a hidden div in the middle it does not do it properly.
Am I wrong about behavior? How to correct?