【问题标题】:JS Scroller doesnt scroll smoothlyJS Scroller 滚动不顺畅
【发布时间】:2016-12-15 05:34:41
【问题描述】:

大家好,我们的首页在这里:http://wp.partyloo.com/

我添加了一个向下滚动箭头,以向下滚动到它正下方的下一部分。

我得到了以下 HTML:

   <a id="scroll" href="#second"><i class="fa fa-angle-down" style="font-size:54px; color: #fff; text-align: center; display: block; margin: 0 auto;" aria-hidden="true"></i></a>

这是我放置的 JS:

$('a[href*="#"]:not([href="#"])').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
      }, 600);
      return false;
    }
  }
});

现在,当您单击箭头时,它不会平滑地向下滚动。当您单击它时,它会自动将您带到下一个 div/部分。

我怎样才能放一些流畅的动画,让它平滑而轻松地向下滚动?

提前致谢!

【问题讨论】:

    标签: javascript jquery html css


    【解决方案1】:

    我想你需要这个?

    http://www.w3schools.com/css/css3_transitions.asp

    a {
        -webkit-transition: width 2s; /* Safari */
        transition: width 2s;
    }
    

    【讨论】:

    • 知道如何解决吗?
    猜你喜欢
    • 2012-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多