出于某种原因,我永远无法清除元素,这只会让人感到困惑!。我试试这个:
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
* html .clearfix { zoom: 1; } /*IE6*/
*:first-child+html .clearfix { zoom: 1; } /*IE7 */
到父元素,没有任何作用!真的很困惑:/
最佳答案
从 html5boilerplate.com 试试这个:
/* The Magnificent Clearfix:
Updated to prevent margin-collapsing on child elements.
j.mp/bestclearfix */
.clearfix:before, .clearfix:after {
content: "\0020";
display: block;
height: 0;
overflow: hidden;
}
.clearfix:after {
clear: both;
}
/* Fix clearfix:
blueprintcss.lighthouseapp.com/projects/15318/tickets/5-extra-margin-padding-bottom-of-page */
.clearfix {
zoom: 1;
}
关于html - 向右浮动后无法清除元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6052179/