スタイルscrollBehaviorプロパティ
例
ページにスムーズなスクロール効果を追加します。
document.documentElement.style.scrollBehavior = "smooth";
定義と使用法
scrollBehaviorプロパティは、ユーザーがスクロール可能なボックス内のリンクをクリックしたときに、まっすぐジャンプするのではなく、スクロール位置をスムーズにアニメーション化するかどうかを指定します。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
scrollBehavior | 61.0 | 79.0 | 36.0 | 14.0 | 48.0 |
構文
object.style.scrollBehavior = "auto|smooth|initial|inherit"
プロパティ値
Value | Description |
---|---|
auto | Default. Allows a straight jump "scroll effect" between elements within the scrolling box. |
smooth | Allows a smooth animated "scroll effect" between elements within the scrolling box. |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
関連ページ
CSSリファレンス:scroll-behaviorプロパティ
❮スタイルオブジェクト