2015-10-30 76 views
1

好吧,我的網頁,我有一個左側的導航,位置如果修復,當我想在索引頁面上添加我的內容,內容出現在導航後面,並沒有啓動之後。需要幫助導航側邊欄和內容CSS

如果我刪除固定位置,那麼它只是在下面。

導航CSS

#nav { 
    height: 100%; 
    width: 18%; 
    background-color: #1C1C1C; 
    position: fixed; 

} 

我甚至試圖把所有的內容股利,但沒有運氣內。

內容DIV

#padding { 
height: auto; 
position: absolute; 
right: 0; 

截圖

enter image description here

+0

你希望你的文字出現在你的導航欄旁邊而不是後面或下面是嗎? – Sim

+0

是的:)它要麼落後或落在下面我不能讓我的內容到一邊:P – Jake

+0

爲內容div添加「margin-left:18%」? – aarjithn

回答

0

我會做margin-left:18%;或稍高周圍內容的容器上。然後,您的內容容器將始終填充導航位置並出現在其旁邊的位置。

+0

好吧,謝謝你,不知道這是否是最好的方式去做。 – Jake

2

只要把一個div裏面內容:

<div id="container"> 
    <div id="nav"> 
     <!-- your navbar markup --> 
    </div> 
    <div id="content"> 
     <!-- your content --> 
    </div> 
</div> 

用CSS,你可以樣式化元素:

#container { 
    width: 100%; 
} 
#nav { 
    height: 100%; 
    width: 18%; 
    background-color: #1C1C1C; 
    float: left; 
} 
#content { 
    width: 82%; 
    float: left; 
} 

隨着float: left你的兩個div出現了一邊。

注:

如果你不想把你的內容的div元素裏面,所以只是float導覽列元素:

#nav { 
    height: 100%; 
    width: 18%; 
    background-color: #1C1C1C; 
    float: left; 
} 

......這一切都和所有內容之後出現(如果可能的話)在你的導航欄的右側。