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
|
---
title: <percentage>
slug: Web/CSS/percentage
translation_of: Web/CSS/percentage
original_slug: Web/CSS/porcentaje
---
<p>{{CSSRef}}</p>
<h2 id="Sumario">Sumario</h2>
<p>Los tipos de dato <code><porcentaje> </code>de <a href="/en/CSS" style="font-size: 14px; line-height: inherit;" title="CSS">CSS</a> representan un valor en forma de porcentaje. Muchas <a href="/en/CSS_Reference">propiedades de CSS</a> pueden tomar valores porcentuales, siempre para definir longitudes con respecto al tamaño de los elementos padre. Los porcentajes estan formados por un <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/number"><numero></a> seguido por el signo de porcentaje <code>%</code>. No hay un espacio entre el '%' y el numero.</p>
<p>Varias propriedades de longitud usan porcentajes, tales como <code><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/width">width</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/margin">margin</a></code> y <code><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/padding">padding</a>. </code>Los porcentajes tambien se pueden ver en <code><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size">font-size</a>, </code>donde el tamaño del texto esta directamente relacionado al tamaño de su elemento padre.</p>
<div class="note"><strong>Nota:</strong> Solo los valores calculados son heredados. Entonces, incluso si un valor porcentual es usado en en la propiedad padre, un valor real, como una anchura en pixeles para un valor <code><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/length"><length></a>, </code>sera accesible en la propiedad heredada, no el valor porcentual.</div>
<h2 id="Interpolación">Interpolación</h2>
<p>Los valores del tipo de dato <code><porcentaje></code> de CSS pueden ser interpolados en orden de permitir animaciones. En ese caso ellos son interpolados como numeros reales de punto flotante. La velocidad de la interpolación se determina por medio de la <a href="/en/CSS/timing-function">funcion de temporizacion</a> asociada con la animacion.</p>
<h2 id="Examples">Examples</h2>
<pre class="brush: html"><div style="background-color:#0000FF;">
<div style="width:50%;margin-left:20%;background-color:#00FF00;">Width: 50%, Left margin: 20%</div>
<div style="width:30%;margin-left:60%;background-color:#FF0000;">Width: 30%, Left margin: 60%</div>
</div>
</pre>
<p>El codigo de arriba se va a renderizar así:</p>
<div style="background-color: #0000FF;">
<div style="width: 50%; margin-left: 20%; background-color: #00FF00;">Width: 50%, Left margin: 20%</div>
<div style="width: 30%; margin-left: 60%; background-color: #FF0000;">Width: 30%, Left margin: 60%</div>
</div>
<p> </p>
<pre class="brush: html"><div style="font-size:18px;">
Full size text (18px)
<span style="font-size:50%;">50%</span>
<span style="font-size:200%;">200%</span>
</div>
</pre>
<p>El codigo de arriba de renderizara así:</p>
<div style="font-size: 18px;">Full size text (18px) <span style="font-size: 50%;">50%</span> <span style="font-size: 200%;">200%</span></div>
<h2 id="Specifications" name="Specifications">Especificaciones</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Especificacion</th>
<th scope="col">Estatus</th>
<th scope="col">Comentarios</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ SpecName('CSS3 Values', '#percentages', '<percentage>') }}</td>
<td>{{ Spec2('CSS3 Values') }}</td>
<td>No hay cambios significantes desde CSS Level 2 (Revision 1)</td>
</tr>
<tr style="vertical-align: top;">
<td style="vertical-align: top;">{{ SpecName('CSS2.1', 'syndata.html#percentage-units', '<percentage>') }}</td>
<td style="vertical-align: top;">{{ Spec2('CSS2.1') }}</td>
<td style="vertical-align: top;">No hay cambios desde CSS Level 1</td>
</tr>
<tr>
<td style="vertical-align: top;">{{ SpecName('CSS1', '#percentage-units', '<percentage>') }}</td>
<td style="vertical-align: top;">{{ Spec2('CSS1') }}</td>
<td style="vertical-align: top;"> </td>
</tr>
</tbody>
</table>
<h2 id="Browser_Compatibility" name="Browser_Compatibility">Compatibilidad de navegadores</h2>
{{Compat("css.types.percentage")}}
|