Свойство стиля 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
❮ Объект стиля