方法一:推荐
设置父div的overflow:hidden;
方法二:
父div结束前增加一个空div style=”clear:both;”
1 .clear { 2 clear:both; 3 } 4 5 <div> 6 <div style=”float:left;”> 7 <div class=” clear” /> 8 </div>
方法三:由方法二变换:
1 .clearfix:after { 2 content: "."; 3 display: block; 4 height: 0; 5 clear: both; 6 visibility: hidden; 7 }
方法四:设定高度