首页 > 开发 > CSS > 正文

IE CSS Bug及解决方案参考手册

2024-07-11 08:39:57
字体:
来源:转载
供稿:网友

当然,还有性能问题。不过,今天要说的是样式的兼容问题。在IE/Mozilla/Webkit/Opera四分天下的今天,IE6-9/Mozilla(Gecko)系列/Chrome/Safari/Opera etc. 这些浏览器的兼容,无不让前端们头痛。而在这之中,最让人头痛的当数IE,特别是IE6。搞定了IE6,基本也就能称霸半个江山了。搞定了IE,也相当于占领了7、80%的领地。你想做一个统治页面兼容的主么?反正我是想的。

问题浏览器DEMO解决方法
Hacking Rules:

 

property:all-ie/9; property:gte-ie8/0;*property:lte-ie7; +property:ie7; _property:ie6;

1input 不能用 margin:0 auto; 居中IE8bug | fixed为input添加width
2body{overflow:hidden;}没有去掉滚动条IE6/7bug | fixed设置html{overflow:hidden;}
3hasLayout的标签拥有高度IE6/7bug | fixed*height:0;
_overflow:hidden;
4form>[hasLayout]元素有margin-left时,子元素中的[input | textarea] 出现2×margin-leftIE6/7bug | fixedform > [hasLayout 元素]{margin-left:宽度;}
form div{*margin-left:宽度÷2;}
5当border-width有1条<边3条时被设置成dotted时,1px的边dotted显示成dashedIE7bug | fixed不在同一个元素上使用不同宽度的 dotted
6当子元素有position:relative的时候,父元素设置overflow:[hidden|auto]相当于给子元素设置了position:visible;IE6/7bug | fixed给父元素设置position:relative;
7:hover伪类不能改变有position:absolute的子级元素的left/top值IE7bug | fixed把top/left的值设置成除0%外的所有百分值;或添加一个margin-[所有方向]除0外的所有值,包括0%
8:focus + selector {} 选择器失效IE8bug | fixed在失效选择器后面添加一个空选择器, :focus{}
9列表中混乱的浮动:在list中浮动图片时,图片出现溢出正常位置;或没有list-styleIE8bug | fixed用背景图片替换list-style
10th 不会自动继承上级元素的 text-alignIE8bug | fixed给th添加text-align:inherit;
11样式(包括link/style/@import(link)) 最多允许个为是:32IE6-8─ 常识99.99%的情况下,不会遇到
12:hover 时若background-color为#fff, 失效IE7bug | fixed把background-color改成background。或者,非#fff || #ffffff
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表