2011-10-05 73 views
2

我有一個包含垂直導航的側邊div,每個頁面上都會有不同數量的內容。如何將背景圖像添加到自動展開高度的div底部

基本上,我想添加一個圖像到div的底部,我希望能夠根據它包含的內容的數量自動擴展。

我該怎麼做?

感謝

+0

你能澄清一下「自動展開」,如果它要填充100%的高度,爲什麼你指定它必須在div的底部?我認爲你的意思是它將從底部擴大? – CambridgeMike

回答

2

假設你可以設置此圖片作爲背景,那麼你可以看看背景位置。

例如:

background-position: center bottom; 
2

你可以把包含您的導航DIV內的圖像,使圖像將始終位於DIV底部的股利和再應用此CSS

.navImg{ 
     width: 100%;   
     position: absolute;   
     top: 0; 
     left: 0; } 


<div id="navigation"> 
    //navigation ul 
<div class="navImg"></div> 
</div> 
+0

不應該是'bottom:0;'而不是'top'? –

1
#menu 
{ 
    float:left; 
    width:50px; 
    border:1px solid black; 
    padding:10px; 
    background:black url(http://tinyurl.com/3brzfja) repeat-x center bottom; 
} 

enter image description here