What is the general floating situation? The CSS float property is typically used in a box, which causes the parent object box to not be opened so that the CSS float floats.
Floating produces style effects
Originally the two black Object box was in the red box, because the float was used for two black boxes, so two black boxes were floating, causing the red box to not open, so the float was created.
To put it simply, floats are caused by the use of float:left or float:right or both.
Second, the fluctuation has negative effect-TOP
1. Background cannot be displayed
Because of the floating, if the parent set (CSS background background) CSS background color or CSS background image, and the parent can not be open, so that the CSS background can not be displayed.
2, the frame can not be open
As in, if the parent set CSS border properties (CSS border), because the child uses the float property, resulting in floating, the parent cannot be open, resulting in the border can not be open with the content.
3, margin padding setting value is not displayed correctly
The value of the CSS margin property is not expressed correctly because of a float that causes the parent child to set the CSS padding. In particular, the padding and margin on the bottom are not displayed correctly.
When an element has a floating property, it has an effect on its parent element or subsequent elements.
There will be a pattern of confusion, which can be solved by clearing floating methods to solve the effects of floating.
Floating Cleanup (Clear):
Value:
None: Default value. Allowed to have floating objects on both sides;
Left: No floating object is allowed
Right: Do not allow floating objects on the left;
Both: Floating objects are not allowed on the left and right sides.
To clear floating methods:
1. The parent setting is appropriate for the CSS height
Set the Fit height style to the parent to clear float.
2. 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;}
3. Add Overflow:hidden to parent element;
Note: If the child element uses the positioning layout, it will be difficult to implement.
4. 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 */
Use of CSS Overflow
How to manage content when you set the object's content beyond its specified height and width.
Overflow:visible "Default value, do not cut content or add scroll bars"
Auto "The object content will be clipped or added when required."
Hidden "Do not display content beyond the object size"
Scroll "Always show scroll bars"
Zoom property: Only browser support for IE kernel, zoom scale.
Sets or retrieves the scale of the object.
Syntax: normal "default value, using the actual size of the object"; number "percent | unsigned floating-point real number. Floating point Real numbers
is 1.0 or a percentage of 100% equals the normal value of this property
Zoom:1 solves the problem of IE6 height adaptation.
CSS Clear Float