一个老外弄的Clearing floats(清除浮动的方法)
一个老外弄的Clearing floats(清除浮动的方法)
发布时间:2016-12-29 来源:查字典编辑
摘要:我常用的都是clear:both;方法,如今在PlanABC看到另外这种方法,特些记录下来。div.container{border:1px...

我常用的都是clear:both;方法,如

<divstyle="clear:both">

<divstyle="float:left"></div>

<divstyle="float:right"></div>

</div>

今在PlanABC看到另外这种方法,特些记录下来。

div.container{

border:1pxsolid#000000;

}

div.left{

width:45%;

float:left;

}

div.right{

width:45%;

float:right;

}

层套关系:container的div包含left和right

最简单合理的清除浮动的方法(红色粗体部分):

div.container{

border:1pxsolid#000000;

overflow:hidden;

width:100%;

}

兼容情况:IE6IE7FFMacIE等

来源地址:http://www.quirksmode.org/css/clearing.html

PS:不过在使用的过程貌似还有小的BUG,淘宝的小马曾碰到过,具体的症状是,IE6中层套清除浮动的div,导致部分链接无法点击。

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新 Div+Css教程学习
热门 Div+Css教程学习
网页设计子分类