I have a CSS table like this:
(this is a reliable simplification of my system)
<div class="table">
<div class="row">
<div class="data">
abc
</div>
</div>
<div class="row">
<div class="data">
def
</div>
</div>
<div class="row">
<div class="data">
ghi
</div>
</div>
<div class="row">
<div class="data">
jkl
</div>
</div>
</div>
And I have a CSS like this:
div.table div.row:not(.hide):nth-child(2n){
background-color: #D7D4DA;
}
div.table div.row:not(.hide):nth-child(2n+1){
background-color: #E4E8EB;
}
.hide{
display:none;
}
The purpose is: When a line is hidden (using the class hide), the styling of the table should remain the same (each line with a different color between the two available). Instead, it get's broken.
According to firefox's firebug, the :nth-child
is applied before the :not
, not after (as I wanted). How can that be solved?
Note: Altering the HTML is a no go. This is something dynamically made using javascript.
My purpose is not to count for the nth-child the lines that are hidden in order to maintain the styling even if the line isn't visible