2015-10-30 72 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; 
} 

......这一切都和所有内容之后出现(如果可能的话)在你的导航栏的右侧。