The magical application of minimum height (min-height) in CSS

Source: Internet
Author: User

The minimum height can be set a box of the minimum height, when its content less time, can also keep box height is certain, beyond the automatic downward extension, but so far, only opera and Mozilla support, IE7 began to support, but IE7 in the test phase, Such official version of the release to the popularization of a period of time may be longer, unless the MS bundled it on an operating system, how on the existing basis (IE6 80-90%), reasonable, the minimum height of the magical?

Assuming there are two box, we need it with a minimum height of 150PX.

Css:

div.box1,div.box2{
width:300px;
min-height:150px;
background:#EEE;
float:left;
margin-right:20px;
}

Xhtml:

<div>IE中没保持最小高度为150px</div>
<div>最小高度可以设定一个BOX的最小高度,
当其内容较少时时,也能保持BOX的高度为一定</div>

Now the effect, ie did not maintain a minimum height of 150px. The solution is to set a height for IE.

* html div.box1,* html div.box2{height: 150px;}

You can also use the CSS Property selector (attribute selectors)

div.box1,div.box2{......height:150px;}
/*IE靠这保持最小高度,超出就自动向下延伸*/
div[class].box1,div[class].box2{height:auto;} 
/*具有类选择符(class)属性的DIV对象*/

IE is not supported by nature, Opera and Mozilla support, read this height. Applicable occasions: Search, articles and other pages (not using 100% height, when the content of the search is less, not too short page.)

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.