2014-03-07 51 views
0

我想創建一個頁面,我想調整頁腳的高度。但我失敗了。 div#F {background:yellow;height: 40px} < - 高度不起作用。請幫忙!CSS頁腳不能調整高度

<html> 
<head> 
<style type="text/css"> 
div#C {margin:auto; width:1200px; height:830px} 
div#H {background:pink;} 
div#Menu {background:pink;} 
div#A {float: left; width:80%; background:red; height:700px} 
div#B {float: right; width: 20%; background:green;height:700px} 
div#F {background:yellow;height: 40px} 
</style> 
<title></title> 
</head> 
<body> 
<div id="C"> 
<div id="H"> 
</div> 
<div style="height: 35px;" id="Menu">Menu</div> 
<div id="A">Left floating div</div> 
<div id="B">Right floating div</div> 
<div id="F">Footer</div> 
</div> 
</body> 
</html> 

回答

1

你需要清除您的浮動元素:

div#F { 
    background:yellow; 
    height: 40px; 
    clear:left; 
} 

jsFiddle example

+0

不'明確:left'它應該是'明確:both'作爲元素雙向浮動'left'和'right' –

+0

@AK - 不,左邊的清理工作完全正常,因爲清除左邊會強制浮動元素下面的div。清除並清除它們也是有效的,但左邊沒有任何問題。 – j08691

+0

我沒有說這是錯誤的我正在告訴你正確的技術:[請您參考](https://developer.mozilla.org/en-US/docs/Web/CSS/clear) –

2

無論是在頁腳添加清楚。

DEMO

div#F {clear:both;background:yellow;height: 40px} 
0

改變你的CSS

div#F {background:yellow;height: 40px;float;left;width:100%;}