关于前端浏览器 IE6bug 解决方案

/* position:fixed IE6bug解决方案 */

/* 让修复IE6 position:fixed不可用的Bug! */

/* 头部固定 */

.fixed-top{position:fixed;bottom:auto;top:0px;}

/* 底部固定 */

.fixed-bottom{position:fixed;bottom:0px;top:auto;}

/* 左侧固定 */

.fixed-left{position:fixed;right:auto;left:0px;}

/* 右侧固定 */

.fixed-right{position:fixed;right:0px;left:auto;}

/* 上面的是除了IE6的主流浏览器通用的方法 /
/
修正IE6振动bug */

* html, * html body{background-image:url(about:blank);background-attachment:fixed;}

/* IE6 头部固定定位 */

* html .fixed-top{position:absolute;bottom:auto;
top:expression(eval(document.documentElement.scrollTop));}

/* IE6 右侧固定定位 */

* html .fixed-right{position:absolute;right:auto;
left:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft, 10)||0)-(parseInt(this.currentStyle.marginRight, 10)||0));}

/* IE6 底部固定定位 */

* html .fixed-bottom{position:absolute;bottom:auto;
top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop, 10)||0)-(parseInt(this.currentStyle.marginBottom, 10)||0)));}

/* IE6 左侧固定定位 */

* html .fixed-left{position:absolute;right:auto;
left:expression(eval(document.documentElement.scrollLeft));}

IE6支持兼容min-width、max-width CSS样式属性
1、IE6支持max-width解决方法

IE6支持最大宽度,解决CSS代码:

.yangshi{max-width:1000px;_width:expression((document.documentElement.clientWidth||document.body.clientWidth)<1000?"1000px":"");overflow:hidden;} 

说明:max-width:1000px; 这个是IE6以上级其它品牌浏览器支持最大范围宽度。而_width:expression((document.documentElement.clientWidth||document.body.clientWidth)<1000?”1000px”:””);overflow:hidden;则是让IE6支持max-width替代CSS代码,但效果和其它版本浏览器相同效果。

让所有浏览器都支持max-width的CSS样式代码,完整:

max-width:1000px;_width:expression((document.documentElement.clientWidth||document.body.clientWidth)<1000?"1000px":"");overflow:hidden;

这里的1000和1000px是你需要的数值,注意3个数值的相同。
设置最大max-width的时候别忘记加上overflow:hidden;

2、IE6支持min-width解决方法

IE6支持最小宽度,解决CSS代码:

.yangshi{min-width:1000px;_width:expression((document.documentElement.clientWidth||document.body.clientWidth)>1000?"1000px":"");}

说明:min-width:1000px; 这个是IE6以上级其它品牌浏览器支持最大范围宽度。而_width:expression((document.documentElement.clientWidth||document.body.clientWidth)>1000?”1000px”:””);则是让IE6支持min-width替代CSS代码,但效果和其它版本浏览器相同效果。
让所有浏览器都支持min-width的CSS样式代码,完整:

min-width:1000px;_width:expression((document.documentElement.clientWidth||document.body.clientWidth)>1000?"1000px":"");

这里的1000和1000px是你需要的数值,注意3个数值的相同。

3、让IE6支持min-width同时又支持max-width解决方法

让IE6即支持最小宽度又支持最大宽度限制设置。这种情况我们常常碰到对图片控制,让不确定大小的图片,如果太宽,不能超出一定范围值,小的时候不控制他的方法,用到CSS代码:
_width:expression(this.scrollWidth > 620 ? “620px” : (this.scrollWidth < 1? “1px” : “auto”));

对图片控制CSS完整代码:

img{max-width:620px;_width:expression(this.scrollWidth > 620 ? "620px" : (this.scrollWidth < 1? "1px" : "auto"));}

这里说明:图片不能超出大于620px的宽度,又不小于1像素的宽度。
让所有浏览器包括IE6浏览器支持最大宽度又支持最小宽度DIV CSS代码:

.yangshi{max-width:620px;min-width:1px;_width:expression(this.scrollWidth > 620 ? "620px" : (this.scrollWidth < 1? "1px" : "auto"));}
    原文作者:Mingdy
    原文地址: https://segmentfault.com/a/1190000002538889
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞