利用:after方法清除浮動(做用於浮動元素的父元素)chrome
.clear { zoom: 1;} /* for ie6/7 */ .clear :after{clear:both; content:"";display:block; visibility:hidden;} /*==for FF/chrome/opera/IE8==*/
bootstrap中清除浮動的方法bootstrap
// Mixin itself .clearfix() { &:before, &:after { content: " "; display: table; } &:after { clear: both; } } // Usage as a Mixin .element { .clearfix(); }