Estilo scrollBehavior Propiedad
Ejemplo
Agregue un efecto de desplazamiento suave a una página:
document.documentElement.style.scrollBehavior = "smooth";
Definición y uso
La propiedad scrollBehavior especifica si animar suavemente la posición de desplazamiento, en lugar de un salto directo, cuando el usuario hace clic en un enlace dentro de un cuadro desplazable.
Compatibilidad con navegador
Property | |||||
---|---|---|---|---|---|
scrollBehavior | 61.0 | 79.0 | 36.0 | 14.0 | 48.0 |
Sintaxis
object.style.scrollBehavior = "auto|smooth|initial|inherit"
Valores de propiedad
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 |
páginas relacionadas
Referencia de CSS: propiedad de comportamiento de desplazamiento
❮ Objeto de estilo