CSS3在IE8上甚至按不同颜色排列 [英] CSS3 On IE8 Odd even row by different color

查看:137
本文介绍了CSS3在IE8上甚至按不同颜色排列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Css代码用于区分不同颜色的奇数和偶数行

I Am Having Css code for differentiating odd and even row by different color

.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

And having table with class .historyLog

<table class="historyLog">
<tr><td></td></tr>
<tr><td></td></tr>
</table>

问题在于,当我使用class属性应用Css时.historyLog i.ie

Problem with me is that when I apply Css using the class attribute .historyLog i.ie

.historyLog tr:nth-child(odd) td {
background-color:blue;
}

IE8不会执行它,我会得到的颜色是相同的颜色所有行是偶数还是奇数。但是如果我在不使用表的class属性的情况下应用css,那么

The IE8 does't execute it and what I will get is same color for all rows whether even or odd. But if I apply css without using the class attribute of table i.e

tr:nth-child(odd) td {
background-color:blue;
}

然后IE8以不同颜色的奇数偶数行执行它。
请帮我解释IE8如何使用表的class属性以不同颜色显示奇数和偶数行。

then IE8 execute it in odd even row with different color. Please help me by giving the answer that how IE8 will show odd and even row by different color using the class attribute of table.

推荐答案

由于IE8不支持CSS3选择器。您可以很好地使用内置的jQuery:odd或:even选择器来实现相同的功能。

Since IE8 doesnot support CSS3 selectors. You could very well use jQuery's in built in :odd or :even selectors to achieve the same functionality.

$(".historyLog tr:odd").css('background-color','blue');
$(".historyLog tr:even").css('background-color','white');

或者您可以使用css类文件

or you could use css class file instead

$(".historyLog tr:odd").addClass("odd");
$(".historyLog tr:even").addClass("even");

这篇关于CSS3在IE8上甚至按不同颜色排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆