代碼說明:背景顏色被「浮動」取消
我正在創建一個帶有三個鏈接的欄。我製作了該欄,並嘗試使用float
,text-align
和width
來分隔鏈接。 (我試圖讓中心鏈接居中,另外兩個距離等距離,並且距離邊等距)。但是,當我最初使用3 divs
(divs
而不是「I」divs
)時,背景顏色消失。所以我搞砸了,並意識到第三個鏈接的浮動導致了這個問題div
。所以我又增加了一個div
(最後的div
),並且使用了一些小文本。但是,由於我不得不在文本中放入文本,所以它會拋棄我的空格。所以我在另一邊(第一個)做了div
來平衡它。但它仍然拋出我的間距沒有浮動然而!
問題(S):
爲什麼有一條線在最後div
的float
財產造成的背景顏色消失?
<div style="padding:0px;margin:0px;background-color:#3C3C3C;">
<div style="color:#3C3C3C;float:left;">
I
</div>
<div style="margin-left:50px;width:20%;float:left;text-align:center;">
<a style="color:#3690B7;" href="">
Hello
</a>
</div>
<div style="width:50%;float:left;text-align:center;">
<a style="color:#3690B7;" href="">
Hello
</a>
</div>
<div style="margin-right:50px;width:20%;float:left;text-align:center;">
<a style="color:#3690B7;" href="">
Hello
</a>
</div>
<div style="color:#3C3C3C;float:right;">
I
</div>
</div>
介意創造一個小提琴? –
哎呀,忘了我不能刪除我自己的問題... derp。標記。 –
當然。繼續前進.. –