兩段CSS,其中3個框,只有一個區別css和css2。
在css1中,box2爲float:left;
,在css2中爲box2中的float:right;
。
對於css1和css2,任何其他的css代碼都是一樣的。
這裏是我的css1。上一個浮動框如何影響下一個浮動框?
body{
margin:0px;
}
div.box{
width:640px;
height:800px;
}
div.box1{
width:500px;
height:100px;
background-color: red;
float:left;
}
div.box2{
width:140px;
height:140px;
background-color: blue;
float:left;
}
div.box3{
width:250px;
height:300px;
background-color: green;
float:left;
}
<div class="box">
<div class="box1">box1
</div>
<div class="box2">box2
</div>
<div class="box3">box3
</div>
</div>
這是我的CSS2。
body{
margin:0px;
}
div.box{
width:640px;
height:800px;
}
div.box1{
width:500px;
height:100px;
background-color:red;
float:left;
}
div.box2{
width:140px;
height:140px;
background-color: blue;
float:right;
}
div.box3{
width:250px;
height:300px;
background-color: green;
float:left;
}
<div class="box">
<div class="box1">box1
</div>
<div class="box2">box2
</div>
<div class="box3">box3
</div>
</div>
CSS的只有一個線之間CSS1和CSS2不同。
在css1中爲什麼
float:left
for box2在css1中會導致box1和bo3之間出現空隙?
在css2中爲什麼
float:right
for box2在css1中導致box1和bo3之間沒有間隙?
請指出css規則
https://www.w3.org/TR/CSS22/visuren.html#float-rules
css1和css2的結果。
你剛纔更新的問題,我的答案是否清楚? ':)' –
我正在尋找z軸來幫助我理解它。 –
哈哈..這是一個虛構的Z軸...只是爲了您的理解。我給了它兩次。大聲笑。 –