Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

z-index is not respected

Tags:

css

z-index

I have this styles:

header{
   width:400px;
   min-height:640px;
   background:#9B9B76;
   float:left;
   z-index:1000;  /*high*/
}
nav{
   width:100%;
   z-index:1001;  /*highest*/
}

nav a{
   float:left;
   width:80%;
   padding:10%;
   font-size:20px;
}
nav a:hover{
   background:#997548;
}
.LevelCnt_1{
    float:left;
    width:300px;
    z-index:1;       /*Lowest*/
    position:absolute;
    left:400px;
    background:#baafa9; 
}

the problem is that visually .LevelCnt_1 stays on top of header if I set left:0px

why is this happening?

like image 325
Toni Michel Caubet Avatar asked Nov 08 '11 09:11

Toni Michel Caubet


1 Answers

z-index only work with position relative, absolute & fixed. So, give position:relative to your header & nav DIV .

Like this

header{
   width:400px;
   min-height:640px;
   background:#9B9B76;
   float:left;
   z-index:1000;  /*high*/
position:relative
}
nav{
   width:100%;
   z-index:1001;  /*highest*/
position:relative
}
like image 187
sandeep Avatar answered Sep 18 '22 16:09

sandeep