>  기사  >  웹 프론트엔드  >  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
WBOY원래의
2016-06-24 11:37:221371검색

例如:

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

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

 第四种方法参考地址:

 

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.