开发者

Div overlapping

开发者 https://www.devze.com 2023-04-03 05:44 出处:网络
I am trying to create two <div>\'s that overlap. The only problem is that the second <div> is in front of the first <div> and it has to be the other way around.I\'ve tried setting th

I am trying to create two <div>'s that overlap. The only problem is that the second <div> is in front of the first <div> and it has to be the other way around. I've tried setting the z-index of the first <div> to 1 but it still does not work.

Here is my code:

 #content{
background-color:pink;  
overflow:auto;
position:relative;

}
#content_1{

width:400px;
height:1600px;
background-color:#000099;
margin:0 auto;
z-index:1;
}
nav{

width:300px;
hei开发者_JS百科ght:500px;
background-color:yellow;


position:absolute;
top:0;  
right:200px;
z-index:0;

}

<div id="container">

  <header> </header>

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

  <footer></footer>
 </div>

How can I make the first div overlap the second?


z-indexing works when both elements share the same stacking context, both are positioned (relative or absolute), and both have a z-index attribute applied. In this case you've only applied the positioning and z indexing attributes to one.


add position absolute to content_1 or add position relative

0

精彩评论

暂无评论...
验证码 换一张
取 消