您的位置:首页 > 其它

IE6、IE7不支持 first-child 属性

2013-12-25 17:49 573 查看
原文地址:http://www.aoao.org.cn/blog/2007/03/first-child/

IE6、IE7不支持 first-child 属性,不过可以用其他办法替代。

#sidebar li:first-child{
border-top-style:none;
}
#sidebar li{
border-top-width:1px;
border-top-style:solid;
border-color:#DAD3D0;
*border-top-style:expression(this.previousSibling==null?"none":"solid");
}


代码解析

*border-top-style:expression(this.previousSibling==null?’none’:"solid’);

只有IE6和IE7能识别此行代码,第一个值’none’就是first-child的值,第二个值’solid’则是其他元素的值。

last-child原理相同,代码如下

#sidebar li:last-child{
border-bottom-style:none;
}
#sidebar li{
border-bottom-width:1px;
border-bottom-style:solid;
border-color:#DAD3D0;
*border-bottom-style:expression(this.nextSibling==null?"none":"solid");
}


现在,IE6和IE7是不是相当于实现了first-child的功能了,CSS就是那么强大!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: