aya*_*aya 5 css internet-explorer
我使用php作为我的web项目,但我需要单独的CSS这个着色补充.
因此,我需要在Firefox和Internet Explorer中运行的代码.
此代码已编写,但在Internet Explorer中不起作用:
.tbl_css col:nth-child(odd){
}
.tbl_css col:nth-child(even){
}
Run Code Online (Sandbox Code Playgroud)
san*_*uda 13
较低版本的IE不支持伪选择.
您可以使用jQuery使其工作:
$(document).ready(function(){
$('table tr:even').addClass('even');
$('table tr:odd').addClass('odd');
});
Run Code Online (Sandbox Code Playgroud)
在CSS中简单地说:
.even{ /* your styles */ }
.odd { /* your styles */ }
Run Code Online (Sandbox Code Playgroud)
:nth-child所有主流浏览器(IE 9 +,FF 3.5+)的最新版本都支持伪选择器.如果您必须支持旧浏览器(例如IE 8),您可以手动分配class="odd",class="even"列或使用JQuery:
$(".tbl_css col:nth-child(2n+1)").addClass("odd");
$(".tbl_css col:nth-child(2n)").addClass("even");
Run Code Online (Sandbox Code Playgroud)
重命名.tbl_css col:nth-child(odd)为.odd.
重命名.tbl_css col:nth-child(even)为.even.
您正在测试哪个版本的IE?
所述nth-child选择器只添加到IE中IE9.以前的版本(IE8及更早版本)不支持它.
如果您需要在旧版本的IE中实现此效果,那么您将需要使用替代技术.最常见的只是在<tr>元素中使用交替的类输出HTML .还有一些JQuery插件可以为您实现此效果.
希望有所帮助.
| 归档时间: |
|
| 查看次数: |
12026 次 |
| 最近记录: |