Why the parent div is not being stretched

Source: Internet
Author: User

Why the parent div is not being stretched:

Under normal circumstances, if the parent object does not have a height set, the child object can open the child object, but if the child object floats and does not clear the float, in the IE8 or FF browser, the parent object is not able to be stretched, and can be stretched under IE6.

code example:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.51texiao.cn/" /><title>Ant Tribe</title><styletype= "Text/css">. Parent{Border:1px solid Red;width:500px;}. First,.second{float: Left;Height:100px;width:100px;Border:1px solid Blue}</style></Head><Body><Divclass= "Parent">  <Divclass= "First"></Div>  <Divclass= "Second"></Div></Div></Body></HTML>

The above code can open the parent div under IE6, but cannot be stretched under the IE8 or FF browser. The workaround is to clear the float. The code is as follows:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.51texiao.cn/" /><title>Ant Tribe</title><styletype= "Text/css">. Parent{Border:1px solid Red;width:500px;Overflow:Hidden}. First,.second{float: Left;Height:100px;width:100px;Border:1px solid Blue}</style></Head><Body><Divclass= "Parent">  <Divclass= "First"></Div>  <Divclass= "Second"></Div></Div></Body></HTML>

The original address is: http://www.51texiao.cn/div_cssjiaocheng/2015/0519/1891.html

The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=4699

Why the parent div is not being stretched

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.