IE6下的CSS BUG枚举

时间:2010-06-11 10:45:00 

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', 500);
11、双边距Bug

当元素浮动时,IE6会错误的把浮动方向的margin值双倍计算。个人觉得较好解决方法是避免float和margin同时使用。

标签:IE6,CSS,bug
0
投稿

猜你喜欢

  • Python常见字典内建函数用法示例

    2022-08-07 08:59:23
  • Python中字符编码简介、方法及使用建议

    2021-10-11 21:58:33
  • 制作一个更漂亮一些的多选列表框

    2007-10-16 13:04:00
  • PHP引用符&的用法详细解析

    2023-10-17 17:25:53
  • JavaScript中String.prototype用法实例

    2024-04-22 22:18:12
  • 百度工程师讲PHP函数的实现原理及性能分析(三)

    2023-10-20 01:33:03
  • 谈PHP生成静态页面分析 模板+缓存+写文件

    2023-11-14 12:44:39
  • sql 分组查询问题

    2024-01-21 05:50:00
  • python的移位操作实现详解

    2021-05-05 22:51:30
  • MySQL语句中的主键和外键使用说明

    2024-01-28 12:49:33
  • php逐行读取txt文件写入数组的方法 <font color=red>原创</font>

    2023-11-14 17:22:07
  • Python排序搜索基本算法之归并排序实例分析

    2023-10-19 04:15:11
  • 利用Python中SocketServer 实现客户端与服务器间非阻塞通信

    2021-05-07 00:16:38
  • 3段Python图像处理的实用代码的分享

    2021-10-19 08:06:58
  • Python实现将数据库一键导出为Excel表格的实例

    2024-01-19 19:47:27
  • Centos7.4环境安装lamp-php7.0教程

    2023-11-16 03:07:24
  • Python实现敏感词过滤的4种方法

    2021-10-01 06:21:08
  • 一个函数解决SQLServer中bigint 转 int带符号时报错问题

    2024-01-19 23:26:36
  • python代码实现烟花实例

    2022-09-13 18:09:18
  • 黄相如:如何做好用户体验

    2008-06-04 17:34:00
  • asp之家 网络编程 m.aspxhome.com