2011-03-31 73 views
0

擴大div#leftcontent的高度請參閱此頁面的完整代碼this鏈接和in the end result使用div#wrap

我的div#wrap(藍色)包含頁面的全部內容,其中有幾個div,其中之一就是#leftcontent想留在頁面底部的高度(即使是#包格

基本上,紅線(在頁面底部)應該坐在藍線(在頁面底部)

回答

1

添加下面的CSS規則:

div#wrap { 
    /* the other css rules for this selector */ 
    position: relative; 
} 

與更換用這個:

div#powered { 
    font-size: 10px; 
    position: absolute; 
    bottom: 2px; 
    right: 2px; 
} 

現場測試:http://jsfiddle.net/moeishaa/VB8L9/

+0

不工作。隨着#wrap的增長,他必須成長。我這樣做是因爲我需要該div #footer對齊#leftcontent的中心,並始終在div的底部#wrap – ridermansb 2011-03-31 00:53:11

0

包含的元素(在這種情況下#wrap)設置爲position:relative,然後設置position:absolute; bottom:0; left:0將工作,但會要求你某種形式的高度元素設置爲你的#包裝div。

0

這是因爲你的div#powered有一個clear:both就可以了。定位該分區的另一種方法是使用定位(確保div#wrapposition:relative):

div#wrap 
{ 
    position:relative; 
} 
div#powered 
{ 
    position:absolute; right:0; bottom:0; 
} 
.clear, div.address /* removed div#powered */ 
{ 
    clear:both; 
} 

See example →

+0

不起作用。隨着#wrap的增長,他必須成長。 我這樣做是因爲我需要div #footer對齊#leftcontent的中心,並始終在div的底部#wrap – ridermansb 2011-03-31 00:52:12