我有 Css 代码用于通过不同颜色区分奇数行和偶数行
.historyLog tr:nth-child(odd) td {
background-color:blue;
}
.historyLog tr.odd td{
background-color: blue;
}
.historyLog tr:nth-child(even) td {
background-color:orange;
}
.historyLog tr.even td{
background-color: orange;
}
并拥有带有 .historyLog 类的表
<table class="historyLog">
<tr><td></td></tr>
<tr><td></td></tr>
</table>
我的问题是,当我使用类属性 .historyLog 应用 Css 时
.historyLog tr:nth-child(odd) td {
background-color:blue;
}
IE8 不会执行它,我将得到的所有行的颜色相同,无论是偶数还是奇数。但是如果我应用 css 而不使用表的类属性,即
tr:nth-child(odd) td {
background-color:blue;
}
然后IE8在奇偶行用不同的颜色执行它。
请帮助我回答IE8如何使用表的类属性以不同的颜色显示奇数行和偶数行。
由于 IE8 不支持 CSS3 选择器。您可以很好地在内置 :odd 或 :even 选择器中使用 jQuery 来实现相同的功能。
$(".historyLog tr:odd").css('background-color','blue');
$(".historyLog tr:even").css('background-color','white');
或者你可以使用 css 类文件代替
$(".historyLog tr:odd").addClass("odd");
$(".historyLog tr:even").addClass("even");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)