2012-10-31 51 views

回答

0

我意识到我需要一个包装容器去做这个。我只是想在一个层次上清除浮动元素。使用Sass pie-clearfix()添加容器; mixin解决了这个问题。

2

下面的ClearFix可能会应用于浮动子元素的父元素,或作为浮动元素下面的元素应用。这应该涵盖IE6 - IE10。

.clear:before, 
.clear:after { 
    content: ""; 
    display: table; 
} 
.clear:after { 
    clear: both; 
} 
.clear { 
    zoom: 1; /* For IE 6/7 (trigger hasLayout) */ 
} 

我个人使用这个ClearFix,但要找出更多有关此ClearFix,看看这个链接:http://css-tricks.com/snippets/css/clear-fix/

希望这有助于!

1

您需要的floatstop添加到包含浮动元素的父元素:

CSS:

.floatstop:after { 
content: "."; 
display :block; 
height :0; 
clear :both; 
visibility :hidden; 
} 
*:first-child+html .floatstop {min-height: 1px;}/* ie7 fix */ 
* html .floatstop {height: 1%;}/* ie6 fix */ 

HTML:

<div class="floatstop"> 
<div>floated div</div> 
<div>floated div</div> 
</div>