html - Z-index settings not working, dropdown menu should be behind file button -


i left out html & css didn't think important in fiddle. i'd menubar behind file button, see expected , actual result images @ bottom.

jsfiddle

html

<div class="menubar">      <div class="dropdown" id="file-btn">       <button href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">file <span class="caret"></span></button>       <ul class="dropdown-menu">         <li><a href="#">action</a></li>         <li><a href="#">another action</a></li>         <li><a href="#">something else here</a></li>         <li role="separator" class="divider"></li>         <li><a href="#">separated link</a></li>         <li role="separator" class="divider"></li>         <li><a href="#">one more separated link</a></li>       </ul>     </div> </div> 

css

html, body {   height: 100%; }  .analysis {   display: flex;   flex-direction: column;   height: 100%; }   /* menubar */  .menubar {   height: 35px;   font-size: 12px;   background-color: #eee;   border: hsl(0, 0%, 75%) solid 1px;   border-right: none;   border-left: none;   position: relative; }  /* views-ctrls-cntnr */  #view-ctrls-cntnr {   display: inline-block;   position: absolute;   left: 50%;   top: 50%;   transform: translate(-50%, -50%); }  #view-ctrls-cntnr button {   font-size: inherit; }   /*view-ctrls-cntnr */  /* file-btn */  #file-btn {   margin-left: 34px;   display: inline-block;   height: 100%;   z-index: 100; }  #file-btn button {   line-height: 30px;   color: black;   background-color: transparent;   border: none; }  #file-btn button:focus {   background-color: white; }  #file-btn:hover {   background-color: rgba(0, 0, 0, 0.0392157); }  /* file-dropdown */  #file-btn .dropdown-menu {   margin-top: -1px;   z-index: 10;   left: -34px;   border-left: none;   border-radius: 0; }  /* file-btn */  /* menubar */ 

expected

enter image description here

actual

enter image description here

try adding following styles #file-btn button

#file-btn button {     /*previous styles*/     position: relative;     z-index: 99; } 

also increase margin-top of dropdown -2 account 1 px border , 1px overlap

#file-btn .dropdown-menu {   margin-top: -2px;   /*other styles*/ } 

updated fiddle


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -