The HTML sub-Div uses floats to automatically open up the size of the parent div.

Source: Internet
Author: User

Floating sub-div to open the parent div several ways:

(1) In the parent Div, add a clear floating sub div<div style= "Clear:both;" ></div>, the DIV does not set any style, only to clear the floating

(2) Set overflow:hidden;zoom:1 in the CSS style of the parent Div ;

(3) Setting the parent Div is also a floating element Float:left, so the disadvantage of setting it is not to use Margin:auto; Implement Center

(4) Set the parent element Display:inline-block;, the disadvantage of this setting is not to use Margin:auto;

(5) Add <br clear= "All" > child elements in parent div

Summary: Which method to use according to their own situation.

Reference Original address: http://www.jb51.net/css/173074.html

Http://www.jb51.net/article/43261.htm

1 <!DOCTYPE HTML>2 <HTML>3 <Head>4  <MetaCharSet= "UTF-8">5  <title>HTML5 Canvas Painting Stamp</title>6  <style>7 . Divcss{8 position:relative;9 width:1024px;Ten Height:Auto; One Border:1px solid #999999; A margin:Auto; -       /*Display:inline-block;*/ -       /*Float:left;*/ the       /*Overflow:hidden; - zoom:1;*/ -     } - . Style{ + position:relative; - width:300px; + Height:400px; A float: Left; at Border:1px solid #aaaaaa; - margin:10px;     -     } -  </style> - </Head>    - <Body> in   <Divclass= "Divcss"> -     <Divclass= "Style"></Div> to     <Divclass= "Style"></Div> +     <Divclass= "Style"></Div> -     <Divstyle= "Clear:both;"></Div>  the   </Div> * </Body> $ </HTML>

The HTML sub-Div uses floats to automatically open up the size of the parent div.

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.