简体   繁体   English

一个浮子在另一个浮子上

[英]one float is on top of another float

All li's are float:left; 所有li都是float:left; And 4th li has climbed on the 1st li. 第四锂已经上升到第一锂。

I want the 4th li to be on it's own and not affect the 1st li. 我希望自己拥有第四李而不影响第一李。

Here's the result http://jsfiddle.net/TomasRR/s9nQ6/6/embedded/result/ 结果是http://jsfiddle.net/TomasRR/s9nQ6/6/embedded/result/

Here's the code http://jsfiddle.net/TomasRR/s9nQ6/6/ 这是代码http://jsfiddle.net/TomasRR/s9nQ6/6/

<ul>
    <li>
        <div class="front">1</div>
        <div class="back">Back</div>
    </li>
    <li>
        <div class="front">2</div>
        <div class="back">Back</div>
    </li>
    <li>
        <div class="front">3</div>
        <div class="back">Back</div>
    </li>
    <li>
        <div class="front">4</div>
        <div class="back">Back</div>
    </li>
</ul>

li {
    height: 150px;
    width: 400px;       
    list-style: none;       
    background: red;        
    float: left;        
    margin-right: 20px;     
    margin-bottom: 50px;
    margin-top: 10px;               
}
.front, .back {
    width: 100%;
    height: 100%;
}
.front {    
    background: gray;

}
.back {
    background: yellow;
}

It appears that the height value you have set for the li s is smaller than the overall height of your blocks that contain both front and back. 您为li设置的高度值似乎小于同时包含正反两面的块的总高度。 When the browser window is made small enough, and the items start to break to a new line, they are going to start 150px down from the last, hence your overlap. 当浏览器窗口变得足够小,并且项目开始换行时,它们将从上一行开始向下移动150px,因此与您重叠。 You either need to hide the back section or adjust the height of your li s to take the full height of the elements into account. 你要么需要隐藏的回款或调整的高度li s到取元素的全高度考虑进去。 You may also want some space (padding or margin) in between the rows when the break to a new line. 换行时,您可能还需要在行之间留一些空间(填充或边距)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM