我有3个div:其中2个是浮动的(向左和向右),第3个应该放在另外两个div之下。我使用clear: both
来做到这一点,但它根本不起作用!
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>
提前感谢您的帮助!
答案 0 :(得分:4)
jsfiddle中的“clear:”和“both”之间有一个不间断的空格,删除它,它会正常工作!
.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;
}