aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/css/flex-shrink/index.html
blob: 314f7a78453182f121ac6a406ae7615c3780c933 (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
---
title: flex-shrink
slug: Web/CSS/flex-shrink
translation_of: Web/CSS/flex-shrink
---
<div>{{CSSRef}}</div>

<p>La propiedad <a href="/en-US/docs/CSS" title="CSS">CSS</a> <strong><code>flex-shrink</code></strong> especifica el factor de contracción de un flex item. Los flex items se encogerán para llenar el contenedor de acuerdo a su número <code>flex-shrink</code> , cuando el tamaño por defecto de los flex items sea mayor al de su contenedor flex container.</p>

<pre class="brush:css no-line-numbers">flex-shrink: 2;
flex-shrink: 0.6;

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

<div class="hidden" id="flex-shrink">
<pre class="brush: html">&lt;div class="grid"&gt;
  &lt;div class="row"&gt;
    &lt;div class="cell"&gt;flex-shrink:
      &lt;div class="container"&gt;
        &lt;div class="item small"&gt;&lt;strong&gt;0.5&lt;/strong&gt; &lt;p&gt;&lt;small&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at purus vitae ipsum hendrerit vulputate quis vitae risus.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;
        &lt;div class="item mid"&gt;&lt;strong&gt;1&lt;/strong&gt; &lt;p&gt;&lt;small&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at purus vitae ipsum hendrerit vulputate quis vitae risus.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;
        &lt;div class="item large"&gt;&lt;strong&gt;3&lt;/strong&gt; &lt;p&gt;&lt;small&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at purus vitae ipsum hendrerit vulputate quis vitae risus.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;</pre>

<pre class="brush: css">html,body {
  height: 100%;
  box-sizing: border-box;
  background: #EEE;
}

.grid {
  width: 100%;
  height: 100%;
  display: flex;
  font: 1em monospace;
}

.row {
  display: flex;
  flex: 1 auto;
  flex-direction: row;
  flex-wrap: wrap;
}

.cell {
  margin: .5em;
  padding: .5em;
  background-color: #FFF;
  overflow: hidden;
  text-align: left;
  flex: 1;
}

.note {
  background: #fff3d4;
  padding: 1em;
  margin: .5em;
  font: .8em sans-serif;
  text-align: left;
  flex: 1;
  white-space: nowrap;
}

.container {
  background: #E4F0F5;
  margin-top: .5em;

  display: flex;
}

.item {
  border: 1px solid black;
  padding: 1em;
}

.small { flex-shrink: 0.5; }
.mid   { flex-shrink: 1; }
.large { flex-shrink: 3; }</pre>
</div>

<div>{{EmbedLiveSample("flex-shrink", "100%", 280, "", "", "example-outcome-frame")}}</div>

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

<p> </p>

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

<p>La propiedad <code>flex-shrink</code> se especifica como un único <code><a href="#&lt;number>">&lt;número&gt;</a></code>.</p>

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

<dl>
 <dt><a id="number" name="number"><code>&lt;número</code>&gt;</a></dt>
 <dd>Véase{{cssxref("&lt;number&gt;")}}. Los valores negativos no son válidos</dd>
</dl>

<h3 id="Sintaxi_formal">Sintaxi formal</h3>

{{csssyntax}}

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

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

<div id="Live_Sample">
<pre class="brush: html">&lt;p&gt;El ancho del contenido es de 500px; el flex-basis de los flex items es 120px.&lt;/p&gt;
&lt;p&gt;A, B, C tiene flex-shrink:1. D y E tienen flex-shrink:2&lt;/p&gt;
&lt;p&gt;El ancho de D y E es menor al de los otros.&lt;/p&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&gt;
</pre>

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

<pre class="brush: css">#content {
  display: flex;
  width: 500px;
}

#content div {
  flex-basis: 120px;
  border: 3px solid rgba(0,0,0,.2);
}

.box {
  flex-shrink: 1;
}

.box1 {
  flex-shrink: 2;
}
</pre>
</div>

<h3 id="Result">Result</h3>

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

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

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

<h2 id="Compatibilidad_con_navegadores">Compatibilidad con navegadores</h2>



<p>{{Compat("css.properties.flex-shrink")}}</p>

<h2 id="Vea_también">Vea también</h2>

<ul>
 <li>CSS Flexbox Guide: <em><a href="/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox">Basic Concepts of Flexbox</a></em></li>
 <li>CSS Flexbox Guide: <em><a href="/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Controlling_Ratios_of_Flex_Items_Along_the_Main_Ax">Controlling Ratios of flex items along the main axis</a></em></li>
</ul>

<p><nobr></nobr></p>