在下面的代碼中,我有兩個div框。第一個是float:left,第二個是clear:left,所以它位於第一個之下。我的問題是爲什麼margin-top:20px沒有推掉第一個div?二格框[第一浮動,第二清除],第二的餘量似乎不推先
<head>
<style>
div { width:100px; height:100px; background-color:green; }
#box1 { float:left; }
#box2 { background-color:red; clear:left; margin-top:20px; }
</style>
</head>
<body>
<div id="box1"></div>
<div id="box2"></div>
</body>
我不不知道爲什麼,但如果你在'#box1'中設置'margin-bottom:20px;'而不是'margin-top:20px;''#box2',你會得到預期的結果。也許它可以幫助你找到原因。當您找到時,請與我們分享。 –