平滑滚动在 github 页面上不起作用

Smooth scrolling doesn't work on github page

我有平滑滚动的问题,但只有当网站用 github 页面 link 打开时...这真的很奇怪,因为如果我用实时服务器打开它,平滑滚动就可以了... 有人知道这是怎么回事吗?一切都更新了,代码是一样的,在我的电脑上和 github.

Link 到项目:https://github.com/Beko44/M-M-Website。 Github 平滑滚动不起作用的页面 - 单击菜单中的 smth 后(左上角)它有点跳跃而不是平滑:https://beko44.github.io/M-M-Website/

谢谢!

如果您打开浏览器控制台,您可能会看到一个错误:

Mixed Content: The page at 'https://beko44.github.io/M-M-Website/' was loaded over HTTPS, but requested an insecure script 'http://code.jquery.com/jquery-3.4.1.min.js'. This request has been blocked; the content must be served over HTTPS.

由于 jQuery 由于此错误而未加载,您的平滑滚动脚本将无法运行。

要解决您的问题,只需将 src 从 jQuery 更改为由 https 在您的 index.html 中提供。

<script
  src="https://code.jquery.com/jquery-3.4.1.min.js"
  integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  crossorigin="anonymous">
</script>