keelerjr12
keelerjr12

Reputation: 1903

Google Maps absolute positioning overlapping fixed position Navbar

Working on an Angular application for a small business and for the life of me cannot solve while Google Maps keeps overlapping the fixed position navbar on the mobile site. When I scroll down, the map overlaps the navbar which is not what I want. I want it to disappear behind it. I've tried setting the z-index on both elements, but nothing works.

Positioning

Here is the html for the location.component.html

<div class="md-6-col" >
    <div #gmap style="width: 100%;height: 450px;"></div>
</div>

Here is the html for the navbar.component.html

<nav class='navbar'>
    <div class='navbar__logo'></div>
    <ul class='navbar__list'>
        <li class='navbar__item'>
            <a class='navbar__link' routerLink='/home' routerLinkActive='navbar__link--active'>
                <i class='navbar__icon navbar__icon--home'></i>
                <p class='navbar__linktext'>Home</p>
            </a>
        </li>
        <li class='navbar__item'>
            <a class='navbar__link' routerLink='/location' routerLinkActive='navbar__link--active'>                
                <i class="navbar__icon navbar__icon--location"></i>
                <p class='navbar__linktext'>Location</p>
            </a>
        </li>
        <li class='navbar__item'>
            <a class='navbar__link' routerLink='/contact' routerLinkActive='navbar__link--active'>                
                <i class="navbar__icon navbar__icon--location"></i>
                <p class='navbar__linktext'>Contact</p>
            </a>
        </li>
    </ul>
</nav>

Here is the css for navbar.component.css

.navbar {
    text-align: center;
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: #4F4F4F;
  }
/*
  .navbar__logo {
    display: inline-block;
    background-image: url('/assets/mobile_logo_150x150.png');
    height: 150px;
    width: 150px;
  }
  */
.navbar__list {
  height: 100%;
  margin: 0;
  padding: 0;
}

.navbar__item {
  align-items: center;
  display: inline-flex;
  height: 100%;
  vertical-align: middle;
  width: 33%;
}

.navbar__link {
  color: #ffffff;
  height: 100%;
  text-decoration-line: none;
  width: 100%;
}

.navbar__link--active {
  font-weight: 900;
  background-color: #363636;
}

.navbar__icon {
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  display:block;
  height: 30px;
  width: 100%;
}

.navbar__icon--home {
  background-image: url('/assets/home-icon.png');
}

.navbar__icon--location {
  background-image: url('/assets/location-icon.png');
}

.navbar__linktext {
  margin: 0;
}

@media screen and (min-width: 480px) {
  .navbar {
    text-align: right;
  }
}

Upvotes: 0

Views: 925

Answers (1)

toothful
toothful

Reputation: 892

Where did you apply position: absolute for map? Make sure you apply position: absolute property to map and position: relative to parent of map to make the z-index working.

Upvotes: 1

Related Questions