Fix the bug that IE6 does not support min height and max height

web front end five thousand three hundred and twenty-two 13 years ago (2010-10-13)

Let's solve it first min-heigt Bugs of
Everyone who has laid out the CSS Minimum height Min height is a very useful attribute, which can make very short content have a suitable height and make the page look beautiful. But it's a pity IE6 This property is not supported. What shall I do? We can use another way to IE6 There are also Minimum height The effect of the min height attribute.

As we all know, if the content exceeds the height of the element, IE6 will automatically increase the height of the element, even if you explicitly define the height of the element. We can use this bug in IE6 to make IE6 have the effect of minimum height min height attribute. The specific codes are as follows:

 height:auto ! important; height:500px; min-height:500px;


1. Because IE6 is right! There is a bug in the important explanation, so it only recognizes the sentence "height: 500px". After exceeding 500px, IE6 will increase the height of the box itself;
2. IE7 and other standards browser All three sentences can be recognized. Although height: 500px is defined, we have height: auto! Important, so the height of the box can also be increased automatically if the box exceeds 500px.

The max heigt bug is troublesome. There are two solutions jQuery method:

 if($.browser.msie&&($.browser.version === "6.0")){$(".entry").each(function()


In IE6, you can set the height to achieve max-height Effect Cycle all to be added max-height The DOM element of the attribute. Judge whether its scrollHeight is greater than the value you want to set Maximum height If it exceeds the limit, set the height to Maximum height , I use [0] here and get the DOM object of instead of jQuery Object.