我看教程里清除浮动标准写法是
.clearfloat:after{display:block;clear:both;content:"";visibility:hidden;height:0} .clearfloat{zoom:1}
但是为什么我这个只是写
#box:after{content:"";clear:both;display:block;}
这么写也能清除浮动,那么visibility和height属性为什么也要写?
附上代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> #box{} .son{width:100px;height:100px;float:left;} #green{background:green;} #red{background:red;} #blue{background:blue;} #black{background:black;} #box:after{content:"";clear:both;display:block;} #box{*zoom:1} </style> </head> <body> <div id="box"> <div id="green" class="son"></div> <div id="red" class="son"></div> <div id="blue" class="son"></div> </div> </body> </html>
第二热情
OlderSkee