让IE6也支持max-width/height和min-width/height(完美解决方案)

来源:互联网 发布:手机淘宝降价提醒设置 编辑:程序博客网 时间:2024/06/05 10:41
1、IE6支持max-width解决方法 IE6支持最大宽度,解决CSS代码:


.className {
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代码:



.className {
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代码:


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

}



1、IE6支持max-height解决方法 IE6支持最大高度解决CSS代码:


.className{
max-height:1000px;
_height:expression((document.documentElement.clientHeight||document.body.clientHeight)<1000?"1000px":"");
overflow:hidden;
}

说明:max-height:1000px; 这个是IE6以上级其它品牌浏览器支持最大范围高度。

而_height:expression((document.documentElement.clientHeight||document.body.clientHeight)<1000?"1000px":"");overflow:hidden;

则是让IE6支持max-height替代CSS代码,但效果和其它版本浏览器相同效果。让所有浏览器都支持max-height的CSS样式代码,完整:

max-height:1000px;_height:expression((document.documentElement.clientHeight||document.body.clientHeight)<1000?"1000px":""); overflow:hidden;

这里的1000和1000px是你需要的数值,注意3个数值的相同。让IE6支持最大高度max-height的时候别忘记加上overflow:hidden;

2、IE6支持min-height解决方法 IE6支持最小高度解决CSS代码:


.className {
min-height:1000px;
_height:expression((document.documentElement.clientHeight||document.body.clientHeight)>1000?"1000px":"");
}

说明:min-height:1000px; 这个是IE6以上级其它品牌浏览器支持最小范围高度。

而_height:expression((document.documentElement.clientHeight||document.body.clientHeight)>1000?"1000px":"");

则是让IE6支持min-height替代CSS代码,但效果和其它版本浏览器相同效果。让所有浏览器都支持min-height的CSS样式代码,完整:

min-height:1000px;_height:expression((document.documentElement.clientHeight||document.body.clientHeight)>1000?"1000px":"");

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

3、IE6支持max-height又支持min-height方法让所有浏览器包括IE6即支持最大高度又支持最小高度。


.className {
Max-Height:620px;
Min-Height:40px;
_height:expression(this.scrollHeight > 620 ? "620px":(this.scrollHeight < 40 ? "40px":"auto"));
}

IE6支持Max-Height和支持Min-Height CSS代码 _height:expression(this.scrollHeight > 620 ? "620px" : (this.scrollHeight < 40 ? "40px" : "auto"));

说明:以上代码作用是让对象的最小高度为40px,最大高度为620px的CSS样式属性

原创粉丝点击