Centered content with right fixed nav causes z-index problem

旧巷老猫 提交于 2019-12-13 18:22:09

问题


I have a centered container layout with a right fixed nav div. To make the fixed nav stay in place when viewport resizes it's set up in some nested divs. Problem is the nav div ends up infront of the content. I can change the z-index order but I want both content and nav to be accesible as in being able to "mark" text for example. Any ideas on this? Below is link to code and and an image showing the layout structure

http://jsbin.com/aliru5/3/edit


回答1:


You are making this more complicated than it needs to be, try this:

<div id="container">
 <div id="content"></div>
 <div id="nav"></div>
</div>

#container {
margin:0 auto; /* center container in browser */
overflow:hidden; /* clear floats */
width:900px
}
#content {float:left;width:640px}
#nav {float:right;width:240px}


来源:https://stackoverflow.com/questions/5778832/centered-content-with-right-fixed-nav-causes-z-index-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!