html - 下拉导航前面的图像 slider

标签 html css drop-down-menu navigation carousel

我使用 Flickity 作为我的图像轮播,下拉菜单一直隐藏在它后面。我试过 z-index: 1000 !important;它仍然无法正常工作。我一直专注于尝试使用 nav CSS 修复它,但我应该考虑尝试使用 Flickity CSS 修复它吗?

这是我的 html:

<section class="navigation">
  <div class="nav-container">
    <div class="brand">
      <a href="#!"><img src="img/LOGO.WELK.png" alt=""></a>
    </div>
    <nav>
      <div class="nav-mobile"><a id="nav-toggle" href="#!"><span></span></a></div>
      <ul class="nav-list">
        <li><a href="#!">Home</a></li>
        <li><a href="about.html">About</a></li>
        <li>
          <a href="#!">Services</a>
          <ul class="nav-dropdown">
            <li>
              <a href="electrical.html">Electrical</a>
            </li>
            <li>
              <a href="#!">Plumbing</a>
            </li>
            <li>
              <a href="#!">Heating</a>
            </li>
             <li>
              <a href="#!">Generators</a>
            </li>
            <li>
              <a href="#!">Bucket Truck</a>
            </li>
          </ul>
        </li>
        <li><a href="contact.html">Contact</a></li>
      </ul>
    </nav>
  </div>
</section>

<section class="portfolio" id="portfolio">
    <div class="wrapper">
      <div class="gallery">
        <div class="galleryItem"><img src="img/electricman.jpg" alt=""></div>
        <div class="galleryItem"><img src="img/electricman.jpg" alt=""></div>
        <div class="galleryItem"><img src="img/LOGO.WELK.png" alt=""></div>
        <div class="galleryItem"><img src="img/LOGO.WELK.png" alt=""></div>
        <div class="galleryItem"><img src="img/LOGO.WELK.png" alt=""></div>
      </div>
    </div>
</section>

我的 CSS:

.navigation {
  height: 120px;
  background: white;
  border-bottom: 4px solid $red;
}

// Logo and branding
.brand {
  position: absolute;
  padding-left: 20px;
  float: left;
  line-height: $nav-height;
  text-transform: uppercase;
  font-size: 1.4em;
  a,
  a:visited {
    text-decoration: none;

    img {
        width: 75%;
        padding: 10px 0;
    }
  }
}

// Container with no padding for navbar
.nav-container {
  max-width: $content-width;
  margin: 0 auto;
}

// Navigation 
nav {
  float: right;
  ul {
    list-style: none;
    margin: 0;
    padding: 0;
    li {
      float: left;
      position: relative;
      a,
      a:visited {
        display: block;
        padding: 40px 20px 0 20px;
        line-height: $nav-height;
        background: white;
        color: black;
        text-decoration: none;
        transition: 0.3s all ease;
        text-transform: uppercase;
        letter-spacing: 1px;
    /////////RIGHTHERE

        &:hover {
          color: $red;
          text-decoration: none;
        }
        &:not(:only-child):after {
          padding-left: 4px;
          content: ' +';
        }
      } // Dropdown list
      ul li {
        min-width: 190px;

        a {
          padding: 15px;
          line-height: 20px;
        }
      }
    }
  }
}

// Dropdown list binds to JS toggle event
.nav-dropdown {
  position: absolute;
  display: none;
  z-index: 20;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}

/* Mobile navigation */

// Binds to JS Toggle
.nav-mobile {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  height: $nav-height;
  width: $nav-height;
}

我的 Flickity CSS 在一个单独的文件夹中。

最佳答案

我遇到了类似的问题,请尝试使用 z-index: 1; 进行导航(必须具有 position 属性)。

关于html - 下拉导航前面的图像 slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48966449/

相关文章:

html - 让包装 div 一直向左清除?

php - 使用复选框、PHP 和 MySQL 删除多行

html - 子菜单的下拉菜单位置

javascript - 使用两个下拉菜单的输入更改按钮上的链接?

javascript - 使用具有最小高度的 jQuery 滑动切换

php - 如何保护 URL 服务的安全?

css - Chrome 不显示 :after pseudo selector

javascript - 我希望文本按顺序出现

jquery - 自定义 css 不在 jquery 移动页面上呈现

html - 如何将此段落移动到图像的右侧