blob: 8af16c2cce1147a678bb70561625acc4876a5cfc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
---
title: scroll-behavior
slug: Web/CSS/scroll-behavior
tags:
- CSS
- Propiedad CSS
- Referencia
- Vista CSSOM
translation_of: Web/CSS/scroll-behavior
---
<div>{{ CSSRef }}</div>
<p><code>La propiedad CSS<strong> </strong></code><strong><code>scroll-behavior </code></strong><code>especifica el comportamiento del desplazamiento para un elemento con desplazamiento, cuando éste se produce debido a la navegación o a APIs CSSOM<strong>. </strong>Otros desplazamientos, p.ej. aquellos realizados por el usuario, no se ven afectados por esta propiedad. Cuando esta propiedad está especificada en el elemento raíz, se aplica al viewport.</code></p>
<p>Esta propiedad puede ser ignorada por los agentes de usuario.</p>
<pre class="brush:css no-line-numbers">/* Keyword values */
scroll-behavior: auto;
scroll-behavior: smooth;
/* Global values */
scroll-behavior: inherit;
scroll-behavior: initial;
scroll-behavior: unset;
</pre>
<p>{{cssinfo}}</p>
<h2 id="Syntax" name="Syntax">Sintaxis</h2>
<p>Valores</p>
<dl>
<dt><code>auto</code></dt>
<dd>La caja de desplazamiento realiza el desplazamiento instantáneamente.</dd>
<dt><code>smooth</code></dt>
<dd>La caja se desplaza suavemente, utilizando una función de tiempo definida por el agente de usuario (user-agent) sobre un período de tiempo también definido por éste. Los agentes de usuario seguirán las convenciones de su propia plataforma, en caso de que existan.</dd>
</dl>
<h3 id="Sintaxis_formal">Sintaxis formal</h3>
{{csssyntax}}
<h2 id="Example" name="Example">Example</h2>
<h3 id="HTML">HTML</h3>
<pre class="brush: html"><nav>
<a href="#page-1">1</a>
<a href="#page-2">2</a>
<a href="#page-3">3</a>
</nav>
<scroll-container>
<scroll-page id="page-1">1</scroll-page>
<scroll-page id="page-2">2</scroll-page>
<scroll-page id="page-3">3</scroll-page>
</scroll-container></pre>
<h3 id="CSS">CSS</h3>
<pre class="brush: css">a {
display: inline-block;
width: 50px;
text-decoration: none;
}
nav, scroll-container {
display: block;
margin: 0 auto;
text-align: center;
}
nav {
width: 339px;
padding: 5px;
border: 1px solid black;
}
scroll-container {
display: block;
width: 350px;
height: 200px;
overflow-y: scroll;
scroll-behavior: smooth;
}
scroll-page {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
font-size: 5em;
}
</pre>
<h3 id="Output">Output</h3>
<p>{{ EmbedLiveSample('Example', "100%", 250) }}</p>
<h2 id="Specifications" name="Specifications">Especificaciones</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Especificación</th>
<th scope="col">Estado</th>
<th scope="col">Comentarios</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('CSSOM View', "#propdef-scroll-behavior", 'scroll-behavior')}}</td>
<td>{{Spec2('CSSOM View')}}</td>
<td>Initial specification</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">Compatibilidad con navegadores</h2>
{{Compat("css.properties.scroll-behavior")}}
|