dan*_*iel 11 html css internet-explorer row css-tables
我使用这个CSS代码在行中显示数据库输出,其中颜色在每第2行重复
tbody tr:nth-child(2n) td, tbody tr.even td {
background: none repeat scroll 0 0 #E5ECF9;
}
Run Code Online (Sandbox Code Playgroud)
如果我在我的IE中打开它将无法正常工作.有什么建议?
我正在使用IE 8.
Šim*_*das 20
IE8不支持:nth-childCSS属性.你可以使用这个脚本使它在IE8中工作:
https://github.com/roylory/ie7-js
如何使用它:
您可以通过条件注释包含它,例如:
<!--[if lte IE 9]>
<script src="IE9.js"></script>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
该脚本仅在IE9及更低版本中加载,其他浏览器不会看到它.
现场演示: https : //jsbin.com/koyahe/edit?html,css, output
(此演示应适用于所有版本的IE.)
我喜欢上面的答案,但如果没有刷新文档,则交替的行颜色似乎不起作用.
尝试jQuery:
$("tbody tr:even td").css("background-color", "lightgray");
Run Code Online (Sandbox Code Playgroud)
链接:http://docs.jquery.com/Tutorials:
Zebra_Striping_Made_Easy