ie不支持max-height的解決之法


.div{ max-height: 100px; _height:expression(this.scrollHeight > 100 ? "100px" : "auto"); overflow-y:auto; } 這樣就可以讓div在ie和firefox中都實現max-height的效果

.div{ max-height: 100px; min-height:60px; _height:expression(this.scrollHeight > 100 ? "100px" : ( this.scrollHeight < 60 ? "60px" : "auto")); overflow-y:auto; } 這樣就可以讓div在ie和firefox中都實現max-height和min-height的效果

 

<html>
<head>
    <title></title>
<head>
<body>
    <div style="max-height:300px;_height:expression(this.scrollHeight>100?'100px':'auto'); overflow:auto;">
        a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>
    </div>
<body>
</html>

 

1、IE6支持max-height解決方法   -   TOP

IE6支持最大高度解決CSS代碼: .yangshi{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解決方法   -   TOP

IE6支持最小高度解決CSS代碼: .yangshi{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支持css 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方法   -   TOP

讓所有瀏覽器包括IE6即支持最大高度又支持最小高度。 .yangshi{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樣式屬性


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM