Css着色表问题 [英] Css coloring table problem
问题描述
我一直在尝试做一个彩色表,偶数行的颜色不同于奇数行。
我唯一的问题是,我必须能够做到隐藏的行,因为如果你隐藏第2行,那么你看到第1行和第3行的颜色相同。
I've been trying to make a colored table with even rows a different color than the odd ones. The only problem I have is that I have to be able to do it even with hidden rows, because if for instance you hide row 2 then you see row 1 and row 3 the same color.
这里是我有:
tr:not([display="none"]):nth-child(even){
background: #EFEFFF;
}
tr:not([display="none"]):nth-child(odd){
background: #E0E0FF;
}
此代码不适用于我,因为浏览器不过滤:not和:nth-child根据给定的顺序。
任何建议?
This code doesn't work for me since browsers don't filter :not and :nth-child according to the given order. Any suggestions?
推荐答案
您可以向可见行添加一个类, p>
Could you add a class to the visible rows so you could write it as:
tr.visible:nth-child(even) {
background: #EFEFFF;
}
tr.visible:nth-child(odd){
background: #E0E0FF;
}
然后使用jquery添加/删除类,因为使行可见/不可见?
Then use jquery to add/remove the class as you make rows visible/invisible?
这篇关于Css着色表问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!