Propriété de style scrollBehavior
Exemple
Ajouter un effet de défilement fluide à une page :
document.documentElement.style.scrollBehavior = "smooth";
Définition et utilisation
La propriété scrollBehavior spécifie s'il faut animer en douceur la position de défilement, au lieu d'un saut direct, lorsque l'utilisateur clique sur un lien dans une boîte défilante.
Prise en charge du navigateur
Property | |||||
---|---|---|---|---|---|
scrollBehavior | 61.0 | 79.0 | 36.0 | 14.0 | 48.0 |
Syntaxe
object.style.scrollBehavior = "auto|smooth|initial|inherit"
Valeurs de propriété
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 |
Pages connexes
Référence CSS : propriété scroll-behavior
❮ Objet de style