Home >Web Front-end >HTML Tutorial >css中table tr:nth-child(even)改变tr背景颜色: IE7,8无效_html/css_WEB-ITnose

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

WBOY
WBOYOriginal
2016-06-24 11:37:221435browse

例如:

.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"))}

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

 第四种方法参考地址:

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn