1. 程式人生 > >3.浮動問題解決方案

3.浮動問題解決方案

部分 nor eight width idt font lin hid 總結

<style> .bar{ /*overflow:hidden;*/    /*BFC解決方案在沒有position情況下使用;應為超出部分會隱藏*/    /*BFC參考第二篇隨筆*/ border:1px solid blue; } .bar:after{ content:""; display:block; clear:both; } .bar{ zoom:1; /*ie專有屬性 清除浮動 ie6 ie7*/ } .child{ float:left;
width:100px; height:100px; border:1px solid red; } </style> <div class="bar"> <div class="child"></div> <div class="child"></div> </div> 總結:兩種解決方案   1.在父元素中加 overflow:hidden;但是在沒有position情況下使用,因為超出部分會被隱藏;   2.在父元素中加     .bar:after{
   content:"";      display:block;    clear:both;   }     .bar{zoom:1; /*ie專有屬性 清除浮動 ie6 ie7*/}  

3.浮動問題解決方案