Clear Clear centralized manner several methods floating floating

Clear several ways of floating

 

Standard streams: cassette half and the entire line will position. If sub-standard streaming box, the father of the box although no height, but the distraction will be the father of the box height.  

Float: box floating up, will not occupy its original position, if the parent does not define the height of the box, the box will not be softened parent, the parent box height of 0. (Floating allows a plurality of block-level elements in one row, and there is no gap between the blocks, but to pay attention to the parent remove floating box, the box will not be softened or parent).

Why do you want to clear float? What is clear is essentially a floating?

  Clear float mainly to solve the internal height of the parent element as a child of the problem is caused by the floating zero.

Clear float method:

1. additional labeling law : to whom clear float, followed by additional add in a blank label.
Advantages: easy to understand, easy to write. (Not recommended)
Cons: add a number of meaningless label, structured relatively poor.

To remove small floating elements (add clear after a small blank label (the class name can be arbitrarily) set clear: both; can)

2. Add the parent overflow methods : triggered by the BFC, to enable a clear Float effect.
Pros: concise code (used with caution, if the parent box as well as position positioning will cause trouble)
Disadvantages: easily lead to an increase in the content of the time would not lead to wrap content to be hidden away, it can not display elements need to overflow.

Note: Do not add the wrong position, the father is to add (not all the floating require clear, who affect the layout, who was cleared.)

3. Clear float after pseudo-elements :: after the way for the upgraded version of the empty element, the benefits are not individually tagged up. (More commonly)
advantages: meet thought closed floating structure semantically correct
disadvantages: Since IE6-7 not support: After, using zoom: 1, trigger hasLayout.

Note: This also added to the father clearfix

4. Using double dummy elements before and after clear float :( more commonly used)

Note: the father is to add clearfix

Standard streams: cassette half and the entire line will position. If sub-standard streaming box, the father of the box although no height, but the distraction will be the father of the box height.  

Float: box floating up, will not occupy its original position, if the parent does not define the height of the box, the box will not be softened parent, the parent box height of 0. (Floating allows a plurality of block-level elements in one row, and there is no gap between the blocks, but to pay attention to the parent remove floating box, the box will not be softened or parent).

Why do you want to clear float? What is clear is essentially a floating?

  Clear float mainly to solve the internal height of the parent element as a child of the problem is caused by the floating zero.

Clear float method:

1. additional labeling law : to whom clear float, followed by additional add in a blank label.
Advantages: easy to understand, easy to write. (Not recommended)
Cons: add a number of meaningless label, structured relatively poor.

To remove small floating elements (add clear after a small blank label (the class name can be arbitrarily) set clear: both; can)

2. Add the parent overflow methods : triggered by the BFC, to enable a clear Float effect.
Pros: concise code (used with caution, if the parent box as well as position positioning will cause trouble)
Disadvantages: easily lead to an increase in the content of the time would not lead to wrap content to be hidden away, it can not display elements need to overflow.

Note: Do not add the wrong position, the father is to add (not all the floating require clear, who affect the layout, who was cleared.)

3. Clear float after pseudo-elements :: after the way for the upgraded version of the empty element, the benefits are not individually tagged up. (More commonly)
advantages: meet thought closed floating structure semantically correct
disadvantages: Since IE6-7 not support: After, using zoom: 1, trigger hasLayout.

Note: This also added to the father clearfix

4. Using double dummy elements before and after clear float :( more commonly used)

Note: the father is to add clearfix

Guess you like

Origin www.cnblogs.com/lee1-w/p/11410478.html