IE6 does not support max-height Solution

Source: Internet
Author: User

The evil IE6 does not support the max-height attribute, but we can use jQuery to solve the problem that IE6 does not support the max-height attribute. The jQuery code is as follows:

$ (". Entry"). each (function (){
If ($ (this) [0]. scrollHeight> 500)
Watermark (this).css ({"height": "500px "});
});
Principle: in IE6, you can set the height to achieve the max-height effect. loop all the DOM elements that need to add the max-height attribute to determine that their scrollHeight is greater than the maximum height you want to set. If the maximum height is exceeded, set the height to the maximum height, I am using [0] Here. The obtained DOM object is not the jQuery object. For details, see: jQuery selector usage details.

The above Code has not been judged by IE6. The complete code is as follows:

If ($. browser. msie & amp; ($. browser. version === "6.0 ")){
$ (". Entry"). each (function (){
If ($ (this) [0]. scrollHeight> 500)
Watermark (this).css ({"height": "500px", "overflow": "hidden "});
});}
Of course, you can also use css expressions to implement IE6 support the max-height attribute.

. Entry {
// Test woshao_985140e4b71711df9e5e000c295b2b8d
Height: expression (this. scrollHeight & gt; 500? "500px": "auto");/* sets max-height

Original article: http://www.js8.in/606.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.