【问题标题】:Smooth Scrolling not working in Chrome anchor平滑滚动在 Chrome 锚点中不起作用
【发布时间】:2017-03-15 07:17:46
【问题描述】:

您好,我无法在 Chrome 中平滑滚动。在其他浏览器中运行良好。它将转到锚点但没有平滑滚动。我还根据 chrome://flags/ 启用了滚动

jquery:

jQuery('.arrow-down').on('click',function (e) {
   e.preventDefault();
    var target = this.hash,
    jQuerytarget = jQuery(target);
    jQuery('html, body').stop().animate({
      'scrollTop': jQuerytarget.offset().top - 60
  }, 1500, 'swing', function () {
      window.location.hash = target;
  });
});

HTML:

<a href="#articleblock1" class="btn arrow-down"><div>SCROLL DOWN</div><i class="fa fa-angle-down" style="line-height:15px;font-size:30px;"></i></a>

【问题讨论】:

    标签: jquery html google-chrome scroll scrolltop


    【解决方案1】:

    您好,我已经弄清楚了。 我的身体上有溢出-x:可见。

    所以我将其更改为溢出:可见并且这有效...不知道为什么..?

    【讨论】:

    • 谢谢!这帮助我弄清楚我在 body 元素上设置的 overflow-y 属性导致了我自己的问题。 :)
    【解决方案2】:
    body {    
        overflow:visible;
    }
    

    这对我有用。将它放在页面的 CSS 中。大约一个月前,Chrome 随机停止了我的 jquery animate scrolltop 代码的工作。很高兴我再次调查了这个,因为我之前找不到任何答案。谢谢 RRowan!

    【讨论】:

      猜你喜欢
      • 2012-12-15
      • 2017-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-19
      相关资源
      最近更新 更多