例如:
.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"))}但是实践的时候发现第四种完全没有反应,如果你实践了有效果,请说说其中的原因吧。
第四种方法参考地址:
立即学习“前端免费学习笔记(深入)”;
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号