清浮动的几种方法

1、clear:both;

.clear{
    clear:both;
    margin:0;
    padding:0;
  }

  可作用于各子元素之间,消除前面子元素浮动对后面子元素的影响。

2、overflow:hidden;

  用在父元素上,作用是消除子元素浮动对父元素产生的影响,但是无法消除,父元素中各个子元素之间浮动的互相影响。

3、:after伪类

.clearfix:after{
    content:".";        
     display:block;        
     height:0;        
     clear:both;        
     visibility:hidden;        
}
原文地址:https://www.cnblogs.com/shaoyizhi-web/p/4087634.html