明确:两者都不能阻止包装

时间:2013-05-17 07:33:39

标签: html css css-float

我有3个div:其中2个是浮动的(向左和向右),第3个应该放在另外两个div之下。我使用clear: both来做到这一点,但它根本不起作用!

http://jsfiddle.net/uYrPY/1/

CSS

.left, .right {
    width: 50px;
    height: 100px;
    background-color: red;
}
.left {float: left;}
.right {float: right;}
.bottom {
    background-color: blue;
    width: 100px;
    height: 100px;
    clear: both;
}

HTML

<div class="left">
</div>
<div class="right">
</div>
<div class="bottom">
</div>

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:4)

jsfiddle中的“clear:”和“both”之间有一个不间断的空格,删除它,它会正常工作!

http://jsfiddle.net/uYrPY/2/

 .left, .right {
    width: 50px;
    height: 100px;
    background-color: red;
}
.left {float: left;}
.right {float: right;}
.bottom {
    background-color: blue;
    width: 100px;
    height: 100px;
    clear: both;
}