滚动动画导航栏

时间:2017-02-08 22:37:40

标签: javascript css3 css-transitions

在桌面上向下滚动页面时 - 导航栏会固定到页面顶部,但似乎没有动画效果。如何添加动画/过渡效果,使其在滚动时自然移动?

代码示例:http://codepen.io/gza/pen/ygjpBy

$('a[href*="#"]:not([href="#slide"])').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
          var target = $(this.hash);
          target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
          if (target.length) {
            $('html, body').animate({
              scrollTop: target.offset().top - 100
            }, 1000);
            return false;
          }
        }
      });
  });

0 个答案:

没有答案
相关问题