2016-01-24 110 views

回答

3

下面是最常用的摘要。

解决方案1:老学校的方式

.clear { 
    clear: both; 
} 

方法2:将溢出的方式

.container { 
    overflow: hidden; /* can also be "auto" */ 
} 

方法3:在“clearfix”类

.clearfix:before, 
.clearfix:after { 
    content: ""; 
    display: table; 
} 

.clearfix:after { 
    clear: both; 
} 

.clearfix { 
    zoom: 1; /* ie 6/7 */ 
} 

如果你不需要支持IE8以下的任何东西

.clearfix:after { 
    content: ""; 
    display: table; 
    clear: both; 
} 

方法4:未来含有-浮动价值

.container { 
    min-height: contain-floats; 
} 

的Src:http://www.sitepoint.com/clearing-floats-overview-different-clearfix-methods/