链接不重定向

时间:2017-03-29 12:02:52

标签: html css

我有一个导航栏,链接无法正常工作.. 但是,当我转到源代码(cntrl + u),然后单击链接时,它会正确地重定向我。 当我删除" class =" menu__link""它运作良好,但没有提供所需的CSS。

<section class="section section--menu" id="Valentine">
    <nav class="menu menu--valentine" style="position: fixed; top: 0px; right: 10px; width: 100%; float: right; background-color: black">
      <ul class="menu__list">
        <li class="menu__item menu__item--current"><a href="#" class="menu__link">Home</a></li>
        <li class="menu__item"><a href="{% url 'speakers' %}" class="menu__link">Speakers</a></li>
        <li class="menu__item"><a href="{% url 'partners' %}" class="menu__link">Partners</a></li>
        <li class="menu__item"><a href="#" class="menu__link">Blog</a></li>
        <li class="menu__item"><a href="#contact" class="menu__link">Contact</a></li>
      </ul>
    </nav>
  </section>

这是我的css菜单。

.section--menu {
 position: relative;
 overflow: ;
 }

.menu {
line-height: 1;
margin: 0 auto 3em;
}
.menu__list {
position: relative;
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
margin: 0;
padding: 0;
float: right;
list-style: none;
}

.menu__item {
display: block;
margin: 1em 0;
}

.menu__link {
font-size: 1.05em;
font-weight: bold;
display: block;
padding: 1em;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-touch-callout: none;
-khtml-user-select: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
 }

.menu__link:hover,
.menu__link:focus {
outline: none;
}


/* Valentine */
.menu--valentine .menu__item {
position: relative;
margin: 0 1em;
}

.menu--valentine .menu__link {
position: relative;
display: block;
min-width: 105px;
text-align: center;
color: #b5b5b5;
-webkit-transition: color 0.3s;
transition: color 0.3s;
}

.menu--valentine .menu__link:hover,
.menu--valentine .menu__link:focus {
color: #e62b1e;
}

.menu--valentine .menu__item--current .menu__link {
color: #e62b1e;
}

.menu--valentine .menu__item::before,
.menu--valentine .menu__item::after,
.menu--valentine .menu__link::before,
.menu--valentine .menu__link::after {
content: '';
position: absolute;
background: #e62b1e;
-webkit-transform-origin: 350% 350%;
transform-origin: 350% 350%;
-webkit-transition: -webkit-transform 0.5s;
transition: transform 0.5s;
-webkit-transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
}

.menu--valentine .menu__item::before,
.menu--valentine .menu__item::after {
top: 0;
width: 2px;
height: 100%;
-webkit-transform: scale3d(1, 0, 1);
transform: scale3d(1, 0, 1);
}

/* left line */
.menu--valentine .menu__item::before {
left: 0;
-webkit-transition-delay: 0.05s;
transition-delay: 0.05s;
}

/* right line */
.menu--valentine .menu__item::after {
right: 0;
-webkit-transition-delay: 0.15s;
transition-delay: 0.15s;
}

.menu--valentine .menu__link::before,
.menu--valentine .menu__link::after {
left: 0;
width: 100%;
height: 2px;
-webkit-transform: scale3d(0, 1, 1);
transform: scale3d(0, 1, 1);
}

/* top line */
.menu--valentine .menu__link::before {
top: 0;
-webkit-transition-delay: 0.1s;
transition-delay: 0.1s;
}

/* bottom line */
.menu--valentine .menu__link::after {
 bottom: 0;
 }

 .menu--valentine .menu__item--current::before,
 .menu--valentine .menu__item--current::after,
 .menu--valentine .menu__item--current .menu__link::before,
 .menu--valentine .menu__item--current .menu__link::after {
 -webkit-transform: scale3d(1, 1, 1);
 transform: scale3d(1, 1, 1);
 }

模板的JS是:

<script>
(function() {
  [].slice.call(document.querySelectorAll('.menu')).forEach(function(menu) {
    var menuItems = menu.querySelectorAll('.menu__link'),
      setCurrent = function(ev) {
        ev.preventDefault();

        var item = ev.target.parentNode; // li

        // return if already current
        if (classie.has(item, 'menu__item--current')) {
          return false;
        }
        // remove current
        classie.remove(menu.querySelector('.menu__item--current'), 'menu__item--current');
        // set current
        classie.add(item, 'menu__item--current');
      };

    [].slice.call(menuItems).forEach(function(el) {
      el.addEventListener('click', setCurrent);
    });
  });

  [].slice.call(document.querySelectorAll('.link-copy')).forEach(function(link) {
    link.setAttribute('data-clipboard-text', location.protocol + '//' + location.host + location.pathname + '#' + link.parentNode.id);
    new Clipboard(link);
    link.addEventListener('click', function() {
      classie.add(link, 'link-copy--animate');
      setTimeout(function() {
        classie.remove(link, 'link-copy--animate');
      }, 300);
    });
  });
})(window);

删除javascript后,链接会起作用,但转换将再次丢失。 提前致谢。

1 个答案:

答案 0 :(得分:1)

删除此css user-select

.menu__link {
font-size: 1.05em;
font-weight: bold;
display: block;
padding: 1em;
cursor: pointer;
/*-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-touch-callout: none;
-khtml-user-select: none;*/
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
 }