Propriedade de comportamento de rolagem CSS
Exemplo
Adicione um efeito de rolagem suave ao documento:
html {
scroll-behavior: smooth;
}
Definição e uso
A scroll-behavior
propriedade 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.
Valor padrão: | auto |
---|---|
Herdado: | não |
Animavel: | não. Leia sobre animáveis |
Versão: | Módulo de Visualização CSSOM (Rascunho de Trabalho) |
Sintaxe JavaScript: | objeto .style.scrollBehavior="smooth" |
Suporte ao navegador
Os números na tabela especificam a primeira versão do navegador que oferece suporte total à propriedade.
Property | |||||
---|---|---|---|---|---|
scroll-behavior | 61.0 | 79.0 | 36.0 | 14.0 | 48.0 |
Sintaxe CSS
scroll-behavior: auto|smooth|initial|inherit;
Valores de propriedade
Value | Description |
---|---|
auto | Allows a straight jump "scroll effect" between elements within the scrolling box. This is default |
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 |