html - Placing div behind two other divs (logo and navbar) -


html:

<!doctype html> <html> <head>     <title>nightfall gaming</title>     <link href="c:\users\cam\desktop\nightfallgaming\css\stylesheet.css" rel="stylesheet" type="text/css"/> </head>  <body bgcolor="#ffffff">   <div id="navbar">     <nav>         <ul>             <li><a href="#">home</a></li>             <li><a href="#">game news</a></li>             <li><a href="#">game reviews</a>             <ul>                 <li><a href="#">xbox 360</a></li>                 <li><a href="#">xbox one</a></li>                 <li><a href="#">ps3</a></li>                 <li><a href="#">ps4</a></li>                 <li><a href="#">pc</a></li>                 <li><a href="#">wii</a></li>             </ul>             </li>             <li><a href="#">contact us/about us</a></li>         </ul>     </nav> </div>  <div id="logo"> <a href="index.html"><img src="c:\users\cam\desktop\nightfallgaming\images\logo.png" alt="home"></a> </div>  <div id="mainbody"></div>  </body> </html> 

css:

body {     font-size:22px;     line-height: 32px;     color: #ffffff;     word-wrap:break-word !important;     font-family: 'open sans', sans-serif;     }  h1 {     font-size: 60px;     text-align: center;     color: #fff; }     h3 {     font-size: 30px;     text-align: center;     color: #fff; }  h3 {     color: #fff; }  {     color: #fff; }  h1 {     margin-top: 100px;     text-align:center;     font-size:60px;     font-family: 'bree serif', 'serif';     }  #container {     margin: 0 auto;     max-width: 890px; }  p {     text-align: center; }  #relatedcontent {   max-width: 800px;   margin: 200px auto; }  #relatedcontent .item {   max-width: 44%;   padding: 3%;   float: left;   text-align: center; }  #relatedcontent .item img {   max-width: 100%; }     #navbar {      margin: 70px 350px;     background-color: #e64a19;     position: absolute;     border: 3px solid black;     text-align: center; }  nav ul {     padding:0;     margin:0;     list-style: none;     position: relative;     }  nav ul li {     display:inline-block;     background-color: #e64a19;     right: 86px;     }  nav {     display:block;     padding:0 10px;      color:#fff;     font-size:20px;     line-height: 60px;     text-decoration:none; }  nav a:hover {      background-color: #000000;  }  /* hide dropdowns default */ nav ul ul {     display: none;     position: absolute;      top: 60px; }  /* display dropdowns on hover */ nav ul li:hover > ul {     display:inherit; }  /* fisrt tier dropdown */ nav ul ul li {     width:170px;     float:none;     display:list-item;     position: relative;     border: 1px solid black; }  /* change in order change dropdown symbol */ li > a:after { content:  ' +'; } li > a:only-child:after { content: ''; }  #logo {     position: absolute;     top: 30px;     left: 70px; }  #mainbody { background: #141414; width: 1500px; height: 800px;   position: absolute; bottom: 0px; left: 50px; } 

i'm trying navbar , site logo show on top of 'mainbody'/background div; of right both of other divs hidden behind 'mainbody' one.

i've seen others posts on suggest use float: left , clear: both solution, hasn't worked in case. others have said might positioning problem.

you need use z-index. z-index specifies stack order of elements. higher number, closer front element be.

here's simplified jsfiddle show in action. took out html , css not necessary example, , changed colours of divs in order see more clearly.

i added 'z-index' of 0 on #mainbody, , z-index of 10 on #logo , #navbar.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -