全屏叠加导航,二级

时间:2018-02-19 10:23:01

标签: javascript jquery navigation overlay fullscreen

我正在尝试使用2级导航创建全屏导航叠加层。

目前,我已设法构建全屏叠加层以及1级导航。

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



redirect

$(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;
}




我现在要做的是:当用户点击服务而不是去服务页面时,我希望在与现有服务页面相同的位置显示第二级菜单(服务1,服务2等)菜单。

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

1 个答案:

答案 0 :(得分:1)

是的,我认为一个简单的jQuery函数与一些CSS结合将是最好的解决方案:

pathlib

Have a look over here(只需点击“服务'”按钮)