1. The parent setting is appropriate for the CSS height
For the parent setting to fit the height style clear float, here to ". Divcss5" set a certain height, the general setting height needs to be able to determine the content height to set. Here we know that the content height is 100px+ the upper and lower border is 2px, so that the specific parent height is 102px
2, Clear:both Clear floating
To unify the style, we create a new style selector CSS named ". Clear", and the corresponding selector style is "Clear:both", then we add this div to the "class=" clear "style before the end of parent </div>". This clears the float.
3. Additional Labeling Method
This method should be the simplest one, and the proposal to add a "clear:both" element at the end of the container
Force the container to fit its height so that all the float elements are loaded.
<div id= "Main" >
<div id= "left" ></div>
<div id= "right" ></div>
<div class= "Clear" ></div>
</div>
<div id= "Footer" ></div>
. Clear{clear:both;}
4. Add Overflow:hidden to parent element;
Note: If the child element uses the positioning layout, it will be difficult to implement.
5. Using pseudo-objects after methods
Defines a class that uses pseudo-objects after, to control the impact of floating elements.
The most popular clear floating code on the Web:
. clearfix:after{
Clear:both;
Display:block;
Visibility:hidden;
height:0;
line-height:0;
Content: ";
}
. clearfix{zoom:1;}/* Resolve IE6/7 compatibility issues */
@copy from http://www.cnblogs.com/zzwlovegfj/archive/2012/08/12/2634313.html
Div+css's clear float