2010-07-28 81 views
2

我有一個div那是我的網站的主體,該div裏面我把一個div左側(具有垂直菜單)調整大小的div是另一個DIV中

http://www.freeimagehosting.net/uploads/117f79fa0e.png http://www.freeimagehosting.net/uploads/4569a5f550.jpg

我的問題是,如何讓菜單div跟在body div的底部,以便它看起來不像它被切割,因爲菜單div的顏色...我玩過屬性像位置,利潤,浮動,但我似乎無法得到它的工作... 我已經包括兩個圖片,以便您可以看到divs!

抱歉圖片不出現,因爲我是一個新用戶!我已經包括鏈接,雖然...

第一張圖片是inital頁面,第二個是內容添加後,身體div擴大,使內容適合!

任何幫助表示讚賞!

+0

你的意思是說,包含你的菜單的div必須是一些固定的大小,不能擴展到適合你將放置在它內部的子元素? – Antony 2010-07-28 23:58:11

回答

1

這真的是最好的CSS接近。

說這是你的結構:

<body> 
<div id="main"> 
    <div id="leftSide"></div> 
</div> 

我想你想要做的就是給左側的100%的高度在你的CSS是什麼:

#main { 
    height:500px; /*this can be whatever height you want for your main div*/ 
    width:700px; /*same with this, for its width*/ 
    background-color:#F00; /*just to show you the effect*/ 
} 

#leftSide { 
    float:left; /*THIS is where the magic happens, to "pull" it to the left*/ 
    height:100%; /*This makes sure it reaches all the way to the bottom*/ 
    background-color:#00F; /*or any color you'd like (which is a great song btw)*/ 
    width:200px; /*or whatever height you'd like*/ 
} 

這一切都假定當然你的div和其他元素沒有額外的邊距和填充。你也可能想要考慮一個「CSS重置」,如this one