菜单滚动问题

问题描述 投票:0回答:1

我的锚链接滚动有问题。

如您所见,它是跳动的/浮躁的,我不知道为什么以及在哪里寻找解决方案。(使用WordPress,elementor和此功能可以平滑滚动)。

我也尝试过“ Page to Id”插件,但由于某种原因,即使我选中了阻止其他任何滚动脚本的选项,它也会变得更加跳跃并且具有怪异的行为。

您可以在这里检查:http://justbutler.sixlogics.com

感谢您的帮助。谢谢。

function smooth_scroll() {
?>
    <script>
        jQuery(document).ready(function($) {
        $(".page-id-27 ul.primary-menu.reset-list-style li a").on('click', function(event) {
            // Make sure this.hash has a value before overriding default behavior
            if (this.hash !== "") {
              // Prevent default anchor click behavior
              event.preventDefault();

              // Store hash
              var hash = this.hash;

              // Using jQuery's animate() method to add smooth page scroll
              // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
              $('html,body').animate({
              scrollTop: $(hash).offset().top - 100
            }, 900);
            return false;
            } // End if
          });
        });
    </script>
<?php

}

php wordpress function
1个回答
0
投票
TwentyTwenty主题中实现的滚动条已损坏。为了解决这个问题,我使用了以下内容:

更新主题。

    [将以下代码添加到您的子主题CSS:html {scroll-behavior:auto!important;}
  1. 安装“ Page to ID” WordPress插件并轻松处理您的滚动。
  • 谢谢您的帮助,我非常感谢。
  • © www.soinside.com 2019 - 2024. All rights reserved.