:打败 IE 的葵花宝典:CSS Bug Table

来源:百度文库 编辑:九乡新闻网 时间:2024/05/08 05:31:17
问题 浏览器 DEMO 解决方法
Hacking Rules:
 
property:all-ie\9; property:gte-ie8\0;*property:lte-ie7; +property:ie7; _property:ie6;
1 input[button | submit] 不能用 margin:0 auto; 居中 IE8bug |fixed 为input添加width
2 body{overflow:hidden;}没有去掉滚动条 IE6/7bug |fixed 设置html{overflow:hidden;}
3 hasLayout的标签拥有高度 IE6/7bug |fixed *height:0;
_overflow:hidden;
4 form>[hasLayout]元素有margin-left时,子元素中的[input | textarea] 出现2×margin-left IE6/7bug |fixed form > [hasLayout 元素]{margin-left:宽度;}
form div{*margin-left:宽度÷2;}
5 当border-width有1条<边3条时被设置成dotted时,1px的边dotted显示成dashed IE7bug |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-style IE8bug |fixed 用背景图片替换list-style
10 th 不会自动继承上级元素的 text-align IE8bug |fixed 给th添加text-align:inherit;
11 样式(包括link/style/@import(link)) 最多允许个为是:32 IE6-8 ─ 常识 99.99%的情况下,不会遇到
12 :hover 时若background-color为#fff, 失效 IE7bug |fixed 把background-color改成background。或者,非#fff || #ffffff
13 忽略’>’后有注释的选择器:selector> /**/ selector{} IE7bug |fixed 官方DEMO有误
14 * html IE6 ─ HACK 只对IE6有效
15 PNG图片中的颜色和背景颜色的值相同,但显示不同 IE6-7bug |fixed 利用pngcrush 去除图片中的 Gamma profiles
16 margin:0 auto; 不能让block元素水平居中 IE6-8bug |fixed 给block元素添加一个width
17 使用伪类 :first-line | :first-letter, 属性的值中出现!important 会使属性失效 IE8bug |fixed !important is evil, don’t use it anymore
18 :first-letter 失效 IE6bug |fixed 把 :first-letter 移到离{}最近的地方,如 h1, p:first-letter{},而非 p:first-letter h1{}
19 Position:absolute元素中,a display:block, 在非:hover时只有文本可点击 IE6/7bug |fixed 给a添加background, 如果背景透明,使用background:url(‘任何页面中已经缓存的文件链接’),不推荐background:url(#)[官方的解决方法],因为会增加一下HTTP请求
20 float列表元素不水平对齐:li不设置float,a设置display:block;float:[方向],li不水平对齐 IE6/7bug |fixed 给li设置display:inline 或 float:[方向]
21 dt, dd, li 背景失效 IE6bug |fixed dt, dd, li{position:relative;}
22