吴旭晓个人博客 繁体中文 简体中文

首页| 日志 |JAVA |ASP |PHP |Android |IOS |ASP.NET |JavaScript |DIV+CSS |SEO |taobaoke |饼哥语录
繁体中文 简体中文

IE6 BUG大全

1、终极方法:条件注释

<!–[if lte IE 6]> 这段文字仅显示在 IE6及IE6以下版本。 <![endif]–>

<!–[if gte IE 6]> 这段文字仅显示在 IE6及IE6以上版本。 <![endif]–>

<!–[if gt IE 6]> 这段文字仅显示在 IE6以上版本(不包含IE6)。 <![endif]–>

<!–[if IE 5.5]> 这段文字仅显示在 IE5.5。 <![endif]–>

<!–在 IE6及IE6以下版本中加载css–>

<!–[if lte IE 6]> <link type=”text/css” rel=”stylesheet” href=”css/ie6.css” mce_href=”css/ie6.css” /><![endif]–>

缺点是在IE浏览器下可能会增加额外的HTTP请求数。

2、CSS选择器区分

IE6不支持子选择器;先针对IE6使用常规申明CSS选择器,然后再用子选择器针对IE7+及其他浏览器。

/* IE6 专用 */

.content {color:red;}

/* 其他浏览器 */

div>p .content {color:blue;} –>

3、PNG半透明图片的问题

虽然可以通过JS等方式解决,但依然存在载入速度等问题,所以,这个在设计上能避免还是尽量避免为好。以达到网站最大优化。

4、IE6下的圆角

IE6不支持CSS3的圆角属性,性价比最高的解决方法就是用图片圆角来替代,或者放弃IE6的圆角。

5、IE6背景闪烁

如果你给链接、按钮用CSS sprites作为背景,你可能会发现在IE6下会有背景图闪烁的现象。造成这个的原因是由于IE6没有将背景图缓存,每次触发hover的时候都会重新 加载,可以用JavaScript设置IE6缓存这些图片:

document.execCommand(“BackgroundImageCache”,false,true);

6、最小高度

IE6 不支持min-height属性,但它却认为height就是最小高度。解决方法:使用ie6不支持但其余浏览器支持的属性!important。

#container {min-height:200px; height:auto !important; height:200px;}

7、最大高度

//直接使用ID来改变元素的最大高度
var container = document.getElementById(‘container’);
container.style.height = (container.scrollHeight > 199) ? “200px” : “auto”;

//写成函数来运行
function setMaxHeight(elementId, height){
var container = document.getElementById(elementId);
container.style.height = (container.scrollHeight > (height – 1)) ? height + “px” : “auto”;
}

//函数示例
setMaxHeight(‘container1′, 200);
setMaxHeight(‘container2′, 500);

8、100% 高度

在IE6下,如果要给元素定义100%高度,必须要明确定义它的父级元素的高度,如果你需要给元素定义满屏的高度,就得先给html和body定义 height:100%;。

9、最小宽度

同max-height和max-width一样,IE6也不支持min-width。

//直接使用ID来改变元素的最小宽度
var container = document.getElementById(‘container’);
container.style.width = (container.clientWidth < width) ? “500px” : “auto”;

//写成函数来运行
function setMinWidth(elementId, width){
var container = document.getElementById(elementId);
container.style.width = (container.clientWidth < width) ? width + “px” : “auto”;
}

//函数示例
setMinWidth(‘container1′, 200);
setMinWidth(‘container2′, 500);

10、最大宽度

//直接使用ID来改变元素的最大宽度
var container = document.getElementById(elementId);
container.style.width = (container.clientWidth > (width – 1)) ? width + “px” : “auto”;

//写成函数来运行
function setMaxWidth(elementId, width){
var container = document.getElementById(elementId);
container.style.width = (container.clientWidth > (width – 1)) ? width + “px” : “auto”;
}

//函数示例
setMaxWidth(‘container1′, 200);
setMaxWidth(‘container2′,

作者:吴旭晓 | 来源:个人博客 | 点击量:4115 | 发布时间:2010-08-31
最新留言 | 返回上一页 | 返回首页

相关文章:

版权所有:吴旭晓个人博客 Copyright © 2013-2023 个人博客