Turn: This article and we will focus on how to control the div minimum height and div adaptive height problem, if we need to set a div height, when the inside of something above this height, let the container automatically open, that is, div adaptive height. When the information inside is seldom, we set it to a minimum fixed height.
How to control div minimum height and div self-fit height
We often encounter a situation when we use div layout: We need to set a div height, when the inside of something above this height, let the container automatically open, that is, div adaptive height. When the information inside is seldom, we set it to a minimum fixed height.
We know that in IE6, if the height of the child container exceeds the parent container, the parent container will open up the container, so we can set a height value directly. But in IE7 and Firefox will not, it will not automatically open.
If you want to set the div adaptive height, we can adopt height:auto; This property, but this property IE6 is not supported. Does it have a headache? In fact, it is not difficult to solve this problem, but also a lot of methods, here is recommended a: (assuming we need to control the div minimum height is 100px, more than let the information inside automatically open):
HTML code
. div{
Height:auto!important;
height:100px;
min-height:100px;
}
. div{height:auto!important; height:100px; min-height:100px;}
Note: Because!important in IE7 and Firefox can read, and the weight is higher than the back of the height:100px, so when the IE7 and Firefox display, will use the previous height:auto!important; And IE6 can not recognize!important,auto to it, so it will apply the style of the following height:100px, and min-height:100px that the div minimum height is 100px; This property is recognized in both IE7 and Firefox.
Such a perfect can set the div minimum height, but also can be div adaptive height CSS style is out, and compatible with IE6, IE7 and firefox!
div default height and adaptive height