CSS Float Parent Element highly adaptive

Source: Internet
Author: User

<HTML><Head><title></title>
<style type= "Text/css" >
*{margin:0; padding:0;}
. content{
border:1px solid red;
}
. Fl{float:left}
</style>
</
Head><Body><Div class= "content"><div class= "FL" >1</div><div class= "FL" >2</div></Div></Body></HTML>

The results are as follows:

Class has a float property that is out of normal document flow, so the parent element is equivalent to no normal document flow fill. With a height of 0, we want the parent node to be highly adaptive to the height of the float element.

Add Overflow:hidden to the parent element; When the box containing float, the height of automatic adaptation in IE invalid, this time should trigger the layout of IE private property (evil ie Ah!). ) with zoom:1, can be done, so that the compatibility is achieved. For example a certain wrapper is defined as follows:. content{Overflow:hidden; zoom:1; margin:5px Auto;}

CSS Float Parent Element highly adaptive

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.