neves
neves

Reputation: 846

CSS property z-index doens't work into Hamburger Menu

I have the follow code:

  @media (max-width: 950px) {
    .navbar-header {
    float: none;
  }
 .navbar-left,.navbar-right {
    float: none !important;
  }
  .navbar-toggle {
    display: block;
  }
  .navbar-collapse {
    border-top: 1px solid transparent;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
  }
  .navbar-fixed-top {
    top: 0;
    border-width: 0 0 1px;
  }
  .navbar-collapse.collapse {
    display: none!important;
  }
  .navbar-nav {
    position: relative !important; 
    display: block !important; /*para o menu hamburger não ficar como "display: flex;"*/
    float: none !important;
    margin-top: 7.5px;
  }
  .navbar-nav>li {
    float: none;
  }
  .navbar-nav>li>a {
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .collapse.in{
    display: block !important;
  }
}

But, the options of .dropdown-menu stay below the other link. See the image:

enter image description here

I tried insert this code in the "Hamburger Menu code":

.navbar-inverse .dropdown-menu>li>a, .navbar-inverse .dropdown-menu>li>a:focus {
  background-color: #008cba;
  z-index: 10;
}

But doesn't work. How to adjust the "hamburger menu code" so that the menu-option is over the other? Link for my application.

Upvotes: 0

Views: 78

Answers (1)

zgood
zgood

Reputation: 12581

You should read about z-index stacking contexts to fully understand what is going on here.

To fix you problem, you can give .navbar-left a z-index: 2, and give .navbar-right a lower z-index: 1

This way stuff inside .navbar-left (the dropdown menu for example) will be over top of stuff inside .navbar-right (where the help icon is)

Upvotes: 2

Related Questions