aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/css/flex-grow/index.html
blob: 0e1e47f8b7d911df916a7d8069a2f211bc5052a8 (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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
---
title: flex-grow
slug: Web/CSS/flex-grow
tags:
  - CSS
  - Elementos flexibles
  - Propiedades CSS
translation_of: Web/CSS/flex-grow
---
<div>{{CSSRef}}</div>

<h2 id="Resumen">Resumen</h2>

<p>La propiedad <strong><code>flex-grow</code></strong> de <a href="/en-US/docs/Web/CSS">CSS</a> especifica el factor de crecimiento de un elemento flexible (que tiene asignado display:flex), en su dirección principal. El factor de crecimiento especifica qué cantidad del espacio restante dentro del contenedor flexible, debería ocupar el item en cuestión.</p>

<p>La dirección principal puede ser la altura o el ancho del elemento, dependiendo del valor de {{cssxref("flex-direction")}}</p>

<p>El espacio restante es el tamaño del contenedor flexible menos el tamaño de todos los elementos flexibles juntos. Si todos los ítems dentro del contenedor tienen el mismo factor de crecimiento, todos los elementos reciben la misma cantidad del espacio restante. De lo contrario, el espacio restante se distribuye en función de los diferentes factores de crecimientos de cada item.</p>

<p>{{cssinfo}}</p>

<p>Ver <a href="/es/docs/Web/CSS/CSS_Flexible_Box_Layout/Usando_las_cajas_flexibles_CSS">Usando las cajas flexibles en CSS</a> para más propiedades e información.</p>

<h2 id="Sintaxis">Sintaxis</h2>

<pre class="brush:css">/* &lt;number&gt; valores */
flex-grow: 3;
flex-grow: 0.6;

/* Valores globales */
flex-grow: inherit;
flex-grow: initial;
flex-grow: unset;
</pre>

<h3 id="Valores">Valores</h3>

<dl>
 <dt><code>&lt;number&gt;</code></dt>
 <dd>Ver {{cssxref("&lt;number&gt;")}}. Los valores negativos no son válidos.</dd>
</dl>

<h3 id="Sintaxis_formal">Sintaxis formal</h3>

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

<h2 id="Ejemplo">Ejemplo</h2>

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

<div id="Live_Sample">
<pre class="brush: html">&lt;h4&gt;This is a Flex-Grow&lt;/h4&gt;
&lt;h5&gt;A,B,C and F are flex-grow:1 . D and E are flex-grow:2 .&lt;/h5&gt;
&lt;div id="content"&gt;
  &lt;div class="box" style="background-color:red;"&gt;A&lt;/div&gt;
  &lt;div class="box" style="background-color:lightblue;"&gt;B&lt;/div&gt;
  &lt;div class="box" style="background-color:yellow;"&gt;C&lt;/div&gt;
  &lt;div class="box1" style="background-color:brown;"&gt;D&lt;/div&gt;
  &lt;div class="box1" style="background-color:lightgreen;"&gt;E&lt;/div&gt;
  &lt;div class="box" style="background-color:brown;"&gt;F&lt;/div&gt;
&lt;/div&gt;
</pre>

<h3 id="CSS">CSS</h3>

<pre class="brush: css">#content {
  -ms-box-orient: horizontal;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -moz-flex;
  display: -webkit-flex;
  display: flex;

  -webkit-justify-content: space-around;
  justify-content: space-around;
  -webkit-flex-flow: row wrap;
  flex-flow: row wrap;
  -webkit-align-items: stretch;
  align-items: stretch;
}

.box {
  flex-grow: 1;
  border: 3px solid rgba(0,0,0,.2);
}

.box1 {
  flex-grow: 2;
  border: 3px solid rgba(0,0,0,.2);
}
</pre>
</div>

<h3 id="Resultado">Resultado</h3>

<p>{{EmbedLiveSample('Example', '700px', '300px', '', 'Web/CSS/flex-grow')}}</p>

<h2 id="Especificaciones">Especificaciones</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Especificación</th>
   <th scope="col">Estado</th>
   <th scope="col">Comentario</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Flexbox','#flex-grow','flex-grow')}}</td>
   <td>{{Spec2('CSS3 Flexbox')}}</td>
   <td>Definición inicial</td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilidad_de_Navegadores">Compatibilidad de Navegadores</h2>

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

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Característica</th>
   <th>Firefox (Gecko)</th>
   <th>Chrome</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Soporte Básico</td>
   <td>{{CompatGeckoDesktop("18.0")}}<sup>[1]</sup></td>
   <td>21.0{{property_prefix("-webkit")}}</td>
   <td>11</td>
   <td>12.10</td>
   <td>6.1{{property_prefix("-webkit")}}</td>
  </tr>
  <tr>
   <td>&lt; 0 animate</td>
   <td>{{CompatGeckoDesktop("32.0")}}<sup>[2]</sup></td>
   <td>49.0</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Característica</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Android</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Soporte Básico</td>
   <td>{{CompatGeckoMobile("18.0")}}<sup>[1]</sup></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>12.10</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td>&lt; 0 animate</td>
   <td>{{CompatGeckoDesktop("32.0")}}<sup>[2]</sup></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Firefox soporta sólo Caja flexible de línea simple hasta Firefox 27. Para activar el soporte de caja flexible para Firefox 18 y 19, el usuario tiene que cambiar en preferencias about:config el <code>layout.css.flexbox.enabled</code> en <code>true</code>.</p>

<p>Además del soporte sin prefijo, Gecko 48.0 {{geckoRelease("48.0")}} añade soporte para un prefijo <code>-webkit</code> en versión porpietaria por razones compatibilidad web bajo la preferencia <code>layout.css.prefixes.webkit</code>, por defecto en <code>false</code>. Desde Gecko 49.0 {{geckoRelease("49.0")}} la preferencia por defecto está en <code>true</code>.</p>

<p>[2] Antes de Firefox 32, Gecko no era capaz de animar los valores de inicio o parada en 0<code>(<a href="https://drafts.csswg.org/css-flexbox-1/#resolve-flexible-lengths">Spec</a><a href="https://jsbin.com/zacifexuke/edit?html,css,output">Demo</a>)</code>.</p>

<h2 id="Ver_también">Ver también</h2>

<ul>
 <li><a href="/es/docs/Web/CSS/CSS_Flexible_Box_Layout/Usando_las_cajas_flexibles_CSS">Usando las cajas flexibles en CSS</a></li>
</ul>