Maison  >  Article  >  interface Web  >  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:221373parcourir

例如:

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

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

 第四种方法参考地址:

 

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn