【问题标题】:Scrollbar and Smooth Scrolling Code滚动条和平滑滚动代码
【发布时间】:2014-01-29 12:08:08
【问题描述】:

请查看此页面(例如)

http://www.christinamichael.in/create-a-powerful-human-disintegration-effect-in-photoshop

我想知道我怎么会有这样的?

我希望在 firefox 和 chrome 中得到支持。

【问题讨论】:

  • 哇,真烦人。我不建议你这样做。我的 Chrome 似乎有一些问题(滚动卡顿)。
  • @FritsvanCampen 真的吗? :-?感谢您的评论

标签: javascript jquery html css scroll


【解决方案1】:

您可以使用 ANCHOR 标签进行平滑滚动。 结果如下。

$(function() {
$('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
    }, 1000);
    return false;
  }
}
  });
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-01
    • 2012-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多