jQuery:自动平滑滚动

3

你是何等的人,能够在没有C#或Java的情况下召唤出代码? - Dave Kelly
2个回答

1

这个例子需要30秒才能滚动到页面底部。

<a href="#bottom">start scrolling</a>

<p> lots of content here </p>

<h2 id="bottom">bottom of page</h2>

<script>
  var oneSecond = 1000;

  $('a').on('click', function() {

      $("html, body").animate({ 
          scrollTop: $(document).height() 
      }, 30 * oneSecond);

      return false;
  });
</script>

你也可以看到。

http://css-tricks.com/snippets/jquery/smooth-scrolling/

并且

jQuery 滚动到页面/iframe 底部

查看其他示例。


0

lmgtfy

听起来你想要一个恒定的速度 - 参数不像那个书签工具那么明确,但你可以调整easing类型和duration以适应你的喜好。

然后只需要将其绑定到$(document).ready即可。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接