Propriedade scrollBehavior de estilo
Exemplo
Adicione um efeito de rolagem suave a uma página:
document.documentElement.style.scrollBehavior = "smooth";
Definição e uso
A propriedade scrollBehavior especifica se deve animar suavemente a posição de rolagem, em vez de um salto direto, quando o usuário clica em um link dentro de uma caixa rolável.
Suporte ao navegador
Property | |||||
---|---|---|---|---|---|
scrollBehavior | 61.0 | 79.0 | 36.0 | 14.0 | 48.0 |
Sintaxe
object.style.scrollBehavior = "auto|smooth|initial|inherit"
Valores de propriedade
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
Referência CSS: propriedade scroll-behavior
❮ Objeto de estilo