全屏覆盖层,具有第二级



我正在尝试创建一个带有2个导航的全屏导航覆盖。

目前,我设法构建了全屏覆盖层以及1级导航。

https://codepen.io/anon/pen/rjjgke

$(document).ready(function() {
  $(".menu-btn a").click(function() {
    $(".overlay").fadeToggle(200);
    $(this).toggleClass('btn-open').toggleClass('btn-close');
  });
  $('.overlay').on('click', function() {
    $(".overlay").fadeToggle(200);
    $(".menu-btn a").toggleClass('btn-open').toggleClass('btn-close');
  });
  $('.menu a').on('click', function() {
    $(".overlay").fadeToggle(200);
    $(".menu-btn a").toggleClass('btn-open').toggleClass('btn-close');
  });
});
/* OPEN / CLOSE BTNS */
.menu-btn {
  z-index: 999;
  display: inline;
  font-size: 32px;
}
.menu-btn a {
  display: inline-block;
  text-decoration: none;
  /* safari hack */
}
.btn-open:after {
  color: #000;
  content: "f394";
  font-family: "Ionicons";
  -webkit-transition: all .2s linear 0s;
  -moz-transition: all .2s linear 0s;
  -o-transition: all .2s linear 0s;
  transition-property: all .2s linear 0s;
}
.btn-open:hover:after {
  color: #000;
}
.btn-close:after {
  color: #000;
  content: "f2d7";
  font-family: "Ionicons";
  -webkit-transition: all .2s linear 0s;
  -moz-transition: all .2s linear 0s;
  -o-transition: all .2s linear 0s;
  transition-property: all .2s linear 0s;
}
.btn-close:hover:after {
  color: #000;
}
/* OVERLAY */
.overlay {
  position: fixed;
  top: 0;
  z-index: 99;
  display: none;
  overflow: auto;
  width: 100%;
  height: 100%;
  background: rgba(135, 119, 116, 0.95);
}
.overlay .menu {
  margin: 100px auto;
  width: 80%;
}
.overlay .menu ul {
  margin: 0;
  padding: 0;
  width: 100%;
}
.overlay .menu ul li {
  float: left;
  padding: 6px 0 0 0;
  width: 100%;
  list-style: none;
  text-align: left;
  text-transform: uppercase;
  margin-bottom: 40px;
}
.overlay .menu ul li#social {
  width: 100%;
  margin-top: 50px;
}
.overlay .menu ul li a {
  color: #d1b400;
  font-weight: 300;
  font-size: 20px;
  font-family: 'Old Standard TT', serif;
}
.overlay .menu ul li#social a {}
.overlay .menu ul ul {
  margin-top: 10px;
}
.overlay .menu ul ul li {
  position: relative;
  float: none;
  margin: 0;
  width: 100%;
  border: 0;
}
.overlay .menu ul ul li a {
  color: #000;
  text-transform: capitalize;
  font-weight: 300;
  font-size: 16px;
  font-family: 'Open Sans', sans-serif;
}
.overlay .menu ul ul li a:hover {
  color: #34b484;
}
/* RESPONSIVE */
@media screen and (max-width: 768px) {
  .overlay .menu ul li {
    float: none;
    margin-bottom: 25px;
    width: 100%;
  }
  .overlay .menu ul li:last-child {
    border: 0;
  }
  .overlay .menu ul ul {
    margin-top: 20px;
  }
  .menu-btn {
    right: 25px;
  }
}
.allexamples {
  position: absolute;
  bottom: 0;
  font-size: 18px;
  font-weight: bold;
  width: 100%;
  text-align: center;
  background: #e9e9e9;
  padding: 20px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  color: #333;
  position: fixed;
}
.menu-social {
  display: inline-block;
  margin: 0 .4em;
}
.menu-social a {
  width: 44px;
  height: 44px;
  padding: 0;
  background-image: url("../img/cd-socials.svg");
  background-repeat: no-repeat;
  /* image replacement */
  overflow: hidden;
  text-indent: 100%;
  white-space: nowrap;
}
.menu-social .menu-facebook a {
  background-position: 0 0;
}
.menu-social .menu-instagram a {
  background-position: -44px 0;
}
.menu-social .menu-dribbble a {
  background-position: -88px 0;
}
.menu-social .menu-twitter a {
  background-position: -132px 0;
}
.overlay .menu ul ul li.description {
  padding: 0px 0 10px 0px;
}
.overlay .menu ul ul li.description span {
  color: #c3bab9;
  font-size: 13px;
  font-weight: 300;
  text-transform: none;
}
p.tel,
p.email {
  margin: 0 0 3px 0;
}
p.tel a {
  font-family: 'Open Sans', sans-serif!important;
  color: #000!important;
  font-weight: 600!important;
  font-size: 18px!important;
  letter-spacing: 1px;
}
p.email a {
  font-family: 'Open Sans', sans-serif!important;
  color: #000!important;
  font-weight: 300!important;
  font-size: 16px!important;
  text-transform: none;
}
.menu-btn a span {
  font-size: 18px;
  color: #000000;
  line-height: 18px;
  font-weight: 600;
  position: relative;
  top: -5px;
  right: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header>
  <nav class="navbar fixed-top">
    <div class="container">
      <a class="navbar-brand" href="#">Logo
        <img src="" width="30" height="30" alt="">
      </a>
      <span class="navbar-text">
        <div class="menu-btn">
          <a class="btn-open" href="javascript:void(0)"><span>MENU</span></a>
        </div>
      </span>
    </div>
  </nav>
</header>
<div class="overlay">
  <div class="menu">
    <div class="container">
      <ul>
        <li>
          <a href="#">Menu</a>
          <ul>
            <li><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Services</a></li>
            <li><a href="#">Work</a></li>
            <li><a href="#">Contact</a></li>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</div>

我现在要做的是:当用户单击服务时,我希望出现第二级菜单(Service 1,Service 2等(,在与现有的位置相同的位置菜单。

这是否需要jQuery解决方案?任何帮助都会很感激。

是的,我认为与某些CSS结合使用的简单jQuery功能将是最好的解决方案:

$('.menu a').on('click', function () {
    $(".overlay").fadeToggle(200);
    $(".menu-btn a").toggleClass('btn-open').toggleClass('btn-close');
    // I added this line
    $(this).next('.sub').toggleClass('visible');
});
.overlay .menu ul li .sub {
  max-height: 0;
  transition: max-height 0.4s ease;
  overflow: hidden;
}
.overlay .menu ul li .sub.visible {
  max-height: 500px;
  transition: max-height 0.4s ease;
}

在这里查看(只需单击"服务"按钮(

相关内容

  • 没有找到相关文章

最新更新