此响应菜单的故障查找解决方案

时间:2018-07-19 09:29:52

标签: javascript jquery

我有这个响应式汉堡菜单,在谷歌浏览器中效果很好。但是它在Internet Explorer上不起作用。在移动版Internet Explorer中进行测试时,菜单显示为静态。当单击菜单图标时,它不会折叠。我试图找出是否由于不兼容。但这似乎不是原因。任何方向对此将不胜感激。

这是代码:

<nav class="site-nav ">
    <ul>
        <li><a href="#"><i class="fa fa-home site-nav--icon"></i>Home</a></li>
        <li><a href="#about"><i class="fa fa-info site-nav--icon"></i>About</a></li>
        <li><a href="#project"><i class="fa fa-pencil site-nav--icon"></i>Projects</a></li>
        <li><a href="#contact"><i class="fa fa-envelope site-nav--icon"></i>Contact</a></li>
    </ul>
</nav>

<div class="menu-toggle">
    <div class="hamburger"></div>
</div>

$(document).ready(function(){

这是我的js:

$('.menu-toggle').click(function() {
    $('.site-nav').toggleClass('site-nav--open', 500);
    $(this).toggleClass('open');
})

这是我的CSS:

.site-nav {
  position: absolute;
  top: 100%;
  right: 2%;
  background-image: -webkit-linear-gradient(0deg, #3e69fe 0%, #4cd4e3 100%);
  clip-path: circle(0px at top right);
  transition: clip-path ease-in-out 700ms;

}

.site-nav--open {
  clip-path: circle(250% at top right);
/*   display: block; */
}

.site-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav li {
  border-bottom: 1px solid #EBEBD3;
}

.site-nav li:last-child {
  border-bottom: none;
}

.site-nav a {
  color: #EBEBD3;
  display: block;
  padding: 2em 4em 2em 1.5em;
  text-transform: uppercase;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a:focus {
  background: transparent;
  color: #464655;
}

.site-nav--icon {
  display: inline-block;
  font-size: 1.5em;
  margin-right: 1em;
  width: 1.1em;
  text-align: right;
  color: rgba(255,255,255,.4);
}

.menu-toggle {
  padding: 1em;
  position: absolute;
  top: .5em;
  right: .5em;
  cursor: pointer;
}

.hamburger,
.hamburger::before,
.hamburger::after {
  content: '';
  display: block;
  background: #EBEBD3;
  height: 3px;
  width: 1.75em;
  border-radius: 3px;
  transition: all ease-in-out 500ms;
}

.hamburger::before {
  transform: translateY(-6px);
}

.hamburger::after {
  transform: translateY(3px);
}

.open .hamburger {
  transform: rotate(45deg);
}

.open .hamburger::before {
  opacity: 0;
}

.open .hamburger::after {
  transform: translateY(-3px) rotate(-90deg);
}

@media (min-width: 750px) {

  .menu-toggle {
    display: none;
  }

  .site-nav {
    height: auto;
    position: relative;
    background: transparent;
    float: right;
    clip-path: initial;
  }

  .site-nav li {
    display: inline-block;
    border: none;
  }

  .site-nav a {
    padding: 0;
    margin-left: 3em;
  }

  .site-nav a:hover,
  .site-nav a:focus {
    background: transparent;
  }

  .site-nav--icon {
    display: none;
  }

}

 header {
     padding: 10px 0;
     position: absolute;
     top: 0;
     left: 0;
     width: 100%;
}
 @media (max-width: 767px) {
     header {
         padding: 15px 0;
    }
}
 .menu-bar {
     cursor: pointer;
}
 .menu-bar span {
     color: #fff;
     font-size: 24px;
}
 .main-menubar {
     position: relative;
}
 @media (max-width: 767px) {
     nav {
         margin-right: 0;
         position: absolute;
         right: 0;
         top: 47px;
         text-align: right;
         padding: 20px 0;
         z-index: 5;
         background-image: -moz-linear-gradient(0deg, #4cd4e3 0%, #3e69fe 100%);
         background-image: -webkit-linear-gradient(0deg, #4cd4e3 0%, #3e69fe 100%);
         background-image: -ms-linear-gradient(0deg, #4cd4e3 0%, #3e69fe 100%);
    }
}
        font - size: 24 px;
    }
    .main - menubar {
        position: relative;
    }
@media(max - width: 767 px) {
    nav {
        margin - right: 0;
        position: absolute;
        right: 0;
        top: 47 px;
        text - align: right;
        padding: 20 px 0;
        z - index: 5;
        background - image: -moz - linear - gradient(0 deg, #4cd4e3 0%, # 3e69 fe 100 % );
        background - image: -webkit - linear - gradient(0 deg, #4cd4e3 0%, # 3e69 fe 100 % );
        background - image: -ms - linear - gradient(0 deg, #4cd4e3 0%, # 3e69 fe 100 % );
    }
}

1 个答案:

答案 0 :(得分:0)

您的代码在IE上不起作用,因为IE仅在SVG元素中支持“剪切路径”。 (MDN web docs