The height of the parent element is not set, the child element content without distraction effect problem

The parent element with child elements are not likely to be sub-element content distraction set up a floating, can solve this problem by clearing the float.

Clear float method:

1. Add the parent element in the overflow: hidden; Zoom:. 1;

 

 2. The parent element to set a fixed height

3. Add the parent div in a floating clearance of the sub-div <div style = "Clear: both;"> </ div> , which does not set any div style, only to clear float

 

 

4. Set the parent div also float a float: left; , disadvantages can not be arranged such that the margin: auto; for centered

The parent element is provided the display: inline-Block; , disadvantages can not be arranged such that the margin: auto; for centered

6. Add the parent div in <br clear="both"> sub-elements

7. references to the parent element style clearfix

  clearfix{

    zoom:1;

  }

  clearfix:after{

    content:"";

    display:block;

    claer: hub;

  }

Guess you like

Origin www.cnblogs.com/-ting/p/11906230.html