当前位置:Gxlcms > html代码 > css中tabletr:nth-child(even)改变tr背景颜色:IE7,8无效_html/css_WEB-ITnose

css中tabletr:nth-child(even)改变tr背景颜色:IE7,8无效_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:66人阅读

例如:

.my_table tr:nth-child(even){background:#E6EDF5;}.my_table tr:nth-child(odd){background:#F0F5FA;}

IE7,8无效,无法识别。

换一种方法:

给需要变色的tr加上class

.table_border table tr.even{background: #f8f8fb;}

方法三:jquery实现

 $(".nav ul li div a:nth-child(even)").css({'background':'red'});$(".nav ul li div a:nth-child(odd)").css({'background':'grey'});

在网上看了看 还有第四种方法:

tr {background-color:expression((this.sectionRowIndex%2==0)?"red":"blue")}td {background-color:expression((this.cellIndex%2==0)?"":((this.parentElement.sectionRowIndex%2==0)?"green":"yellow"))}

但是实践的时候发现第四种完全没有反应,如果你实践了有效果,请说说其中的原因吧。

第四种方法参考地址:

人气教程排行