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.