惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Check Point Blog
Hacker News: Ask HN
Hacker News: Ask HN
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
WordPress大学
WordPress大学
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
N
Netflix TechBlog - Medium
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 聂微东
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 叶小钗
Cisco Talos Blog
Cisco Talos Blog
S
Schneier on Security
T
Threat Research - Cisco Blogs
腾讯CDC
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Hacker News
The Hacker News
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
GbyAI
GbyAI
N
News | PayPal Newsroom
L
LINUX DO - 最新话题
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Palo Alto Networks Blog
T
Tenable Blog
S
Secure Thoughts
T
Threatpost
V2EX - 技术
V2EX - 技术
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Vercel News
Vercel News
罗磊的独立博客
P
Privacy & Cybersecurity Law Blog
Engineering at Meta
Engineering at Meta
小众软件
小众软件
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
Y
Y Combinator Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
P
Privacy International News Feed
H
Heimdal Security Blog
量子位
B
Blog

博客园 - ifishing

VI操作 HTML中小meta的大作用【转】 10种AJAX/JavaScript特效实例让你的网站更吸引人 10 Smart Javascript Techniques to Improve Your UI [译] JavaScript核心指南(JavaScript Core) 【转】 IE7浏览器模式中表格tr/td渲染的一个bug 强制将IE8设置为IE7兼容模式来解析网页【转】 jquery 模块拖拽【转】 jquery的Theme和Theme Switcher使用【转】 三谈Iframe自适应高度【转】 ff3.5已不再支持 -moz-opacity[转] 玩转jquery插件之flexigrid 【转】 JS实例:网页上图片延迟加载的JS代码 图片预加载并且自动等比例缩放的JS插件[转] jQuery表格插件:帮助Web设计者驾御HTML表格【转】 IE9允许前端开发获取到页面性能数据 Web开发者必须收藏的十大网站【转】 【转】打开,另存为,属性等14个javascript代码 【转】js实现另存为的方法 - ifishing - 博客园
打败 IE 的葵花宝典:CSS Bug Table【转】
ifishing · 2010-08-02 · via 博客园 - ifishing

原文地址:http://ued.alipay.com/2010/07/ie-beat-the-holy-canon-css-bug-table/

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

今天,趁着想完善公司的内部样式框架,把HasLayout.net的IE CSS Bug过了一遍。整理中收获了不少东西,一些官方的不足,也根据自己的知识升级了一下。当然,也顺利地升级了框架的一些内容,感觉甚爽。随后,便将一些值得去看的Bug整理成一个列表,基于Alipay前端伟大的分享精神,分享出来以供团队工友们和大家参考。

同时,由于整理仓促,有些理解和表达不当和其他纰漏在所难免,还请大家帮忙更正。谢谢。

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

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

1input[button | submit] 不能用 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
13忽略’>’后有注释的选择器:selector> /**/ selector{}IE7bug | fixed官方DEMO有误
14* htmlIE6─ HACK只对IE6有效
15PNG图片中的颜色和背景颜色的值相同,但显示不同IE6-7bug | fixed利用 pngcrush 去除图片中的 Gamma profiles
16margin: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{}
19Position:absolute元素中,a display:block, 在非:hover时只有文本可点击IE6/7bug | fixed给a添加background, 如果背景透明,使用background:url(‘任何页面中已经缓存的文件链接’),不推荐background:url(#)[官方的解决方法],因为会增加一下HTTP请求
20float列表元素不水平对齐:li不设置float,a设置display:block;float:[方向],li不水平对齐IE6/7bug | fixed给li设置display:inline 或 float:[方向]
21dt, dd, li 背景失效IE6bug | fixeddt, dd, li{position:relative;}
22<noscript />元素的样式在启用javascript的情况下显示了样式IE6-8bug | fixed利用js给<noscript />添加display:none;
23使用filter处理的透明背景图片的透明部分不可点IE6-8bug | fixed把background:none变成background:url(‘链接’),链接到本身和图片之外的任何文件
24li内元素偏离 baseline 向下拉IE8bug | fixed给li设置display:inline 或 float:[方向]
25列表中li的list-style不显示IE6/7bug | fixed给li添加margin-left,留空间来显示(不要加在ul上)
26图片不能垂直居中IE6/7bug/fixed添加一个空标签,并赋给”Layout”, 比如display:inline-block;
27不能自定义指针样式IE6-8bug | fixed给指针文件设置绝对路径
28背景溢出,拖动滚动条后显示正常IE6bug | fixed给父元素添加overflow:hidden防止溢出,并赋予hasLayout,如果添加_zoom:1;
29高度超过height定义的高IE6bug/fixed添加_overflow:hidden;(推荐)或者_font-size:0;
30宽度超过width定义的宽IE6bug/fixed添加_overflow:hidden;
31双倍边距IE6─ 常识添加display:inline到float元素中
32margin负值隐藏:hasLayout的父元素内的非hasLayout元素,使用负边距时,超出父元素部分不可见IE6/7bug/fixed去掉父元素的hasLayout;或者赋hasLayout给子元素,并添加position:relative;
33给两个浮动元素的某中一个的文字设定为斜体,另一个元素下拉在有斜体文字元素的下面IE6bug/fixed给有斜体文字的元素添加overflow:hidden;
353px 间隔:在float元素后的元素,会有3px间隔IE6bug/fixed因为是确切的3px,所以,用“暴力破解”吧,比如_margin-left:-3px;
35text-align 影响块级元素IE6/7bug/fixed整理你的float;或者分开设置text-align