html - 谷歌地图绝对定位重叠固定位置Navbar

标签 html css angular

为小型企业和我的生活开发 Angular 应用程序无法解决,而 Google map 一直与移动站点上的固定位置导航栏重叠。当我向下滚动时, map 与导航栏重叠,这不是我想要的。我想让它消失在它后面。我已尝试在两个元素上设置 z-index,但没有任何效果。

Positioning

这是 location.component.html

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

这是 navbar.component.html

的 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>

这是 navbar.component.css

的 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;
  }
}

最佳答案

你在哪里应用了 position: absolute map ? 确保将 position: absolute 属性应用于 map 和 position: relative 到 map 的父级以使 z-index 正常工作。

关于html - 谷歌地图绝对定位重叠固定位置Navbar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57503820/

相关文章:

css - Django-filer 在管理站点中呈现不正确

css - 如何在没有不透明度的情况下使用 CSS 淡化图像?

Angular 2 <mat-expansion-panel> 展开和折叠所有

angular - typescript :即使正确解析了导入,IntelliJ 也会在导入时显示错误

jquery - 使用 jquery 将类添加到 nth-child

html - 鼠标从悬停位置移动后的 CSS

html - 图像左对齐不适用于 html 和 css 中的 li 标签

css - 我如何更改此 CSS 以使其仅适用于特定的 div?

angular - 检查是否需要 NgControl

ruby-on-rails - Rails 应用程序未加载 mp3 文件以在 HTML 5 播放器中播放