aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/css/scroll-behavior/index.html
blob: b7b591d5202b73f9c241b9d87a7a9b292c68fec9 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---
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>

<pre class="syntaxbox">{{csssyntax}}</pre>

<h2 id="Example" name="Example">Example</h2>

<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;nav&gt;
  &lt;a href="#page-1"&gt;1&lt;/a&gt;
  &lt;a href="#page-2"&gt;2&lt;/a&gt;
  &lt;a href="#page-3"&gt;3&lt;/a&gt;
&lt;/nav&gt;
&lt;scroll-container&gt;
  &lt;scroll-page id="page-1"&gt;1&lt;/scroll-page&gt;
  &lt;scroll-page id="page-2"&gt;2&lt;/scroll-page&gt;
  &lt;scroll-page id="page-3"&gt;3&lt;/scroll-page&gt;
&lt;/scroll-container&gt;</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>

<p>{{ CompatibilityTable }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Característica</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Soporte básico</td>
   <td>61<sup>[1]</sup></td>
   <td>{{ CompatGeckoDesktop("36") }}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}<sup>[1]</sup></td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Soporte básico</td>
   <td>{{CompatNo}}</td>
   <td>{{ CompatGeckoDesktop("36") }}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Soportado en Chrome and Opera activando las opciones"<strong>Smooth Scrolling</strong>" o "<strong>Enable experimental web platform features</strong>".</p>