1、【.clr{clear:both;}】,設置了clear屬性的元素,其上邊框會緊貼著浮動元素的margin-bottom邊界位置渲染,忽略其margin-top設置。
復制代碼代碼如下:
.divcss5{ width:400px;border:1px solid #F00;background:#FF0}
.divcss5-left,.divcss5-right{width:180px;height:100px;
border:1px solid #00F;background:#FFF}
.divcss5-left{ float:left}
.divcss5-right{ float:right}
.clear{ clear:both}
2、空標簽清浮動:【.clr{clear:both;height:0;overflow:hidden;}】,不推薦。
3、偽類after清浮動:【.clr:after{content:" ";clear:both;display:block;height:0;visibility:hidden;line-height:0;} .clr{zoom:1}】。
4、使用【display:table】。
5、使用overflow除visible,類似于激發haslayout。
6、使用浮動父元素清浮動。
復制代碼代碼如下:
.divcss5{ width:400px;border:1px solid #F00;background:#FF0; overflow:hidden}
.divcss5-left,.divcss5-right{width:180px;height:100px;
border:1px solid #00F;background:#FFF}
.divcss5-left{ float:left}
.divcss5-right{ float:right}
新聞熱點
疑難解答