<分区>
最佳答案
这里是最常用的总结。
解决方案 1:老派方法
.clear {
clear: both;
}
方法二:溢出法
.container {
overflow: hidden; /* can also be "auto" */
}
方法 3:“clearfix”类
.clearfix:before,
.clearfix:after {
content: "";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
zoom: 1; /* ie 6/7 */
}
如果您不需要支持 IE8 以下的任何东西
.clearfix:after {
content: "";
display: table;
clear: both;
}
方法四:Future contain-floats Value
.container {
min-height: contain-floats;
}
来源:http://www.sitepoint.com/clearing-floats-overview-different-clearfix-methods/
关于css - 哪些 clearfixes 支持哪些浏览器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34975658/
相关文章:
html - 如何使用具有倾斜边框装饰的相邻 div 实现双边框
HTML:当有人单击我网站上的链接时,浏览器会打开 2 个选项卡?
html - 为什么 clearfix hack 只适用于 float 元素?
css - 有没有办法将 clearfix hack 与 flexbox 一起使用?
css - HTML5Boilerplate 的 Clearfix 类未放置在包含元素上
html - Clearfix 不适用于 float : left and float: right in <ol>