禁用Bootstrap 5中的平滑滚动,使用html/css代码

huangapple go评论63阅读模式
英文:

Disable smooth scroll in Bootstrap 5 with html/css code

问题

I have some anchor links on my website, and when clicking on them - smooth scroll (Bootstrap feature) turns on and it scrolls smoothly.

Due to the specificity of my website I need to disable smooth scrolling in my html or css code.

Thanks in advance!

Found some solutions with some js code, but it's not what I need.

英文:

I have some anchor links on my website, and when clicking on them - smooth scroll (Bootstrap feature) turns on and it scrolls smoothly.

Due to the specificity of my website I need to disable smooth scrolling in my html or css code.

Thanks in advance!

Found some solutions with some js code, but it's not what I need.

答案1

得分: 2

你可以通过在CSS中使用scroll-behavior属性来禁用平滑滚动(在Bootstrap 5中有scroll-behavior: smooth)。

html {
    scroll-behavior: auto !important;
}
英文:

You can disable smooth scrolling by using the scroll-behavior property in CSS (there is scroll-behavior: smooth in Bootstrap 5).

html {
    scroll-behavior: auto !important;
}

huangapple
  • 本文由 发表于 2023年2月7日 04:54:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75366493.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定