aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/css/max-width/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/es/web/css/max-width/index.html')
-rw-r--r--files/es/web/css/max-width/index.html158
1 files changed, 158 insertions, 0 deletions
diff --git a/files/es/web/css/max-width/index.html b/files/es/web/css/max-width/index.html
new file mode 100644
index 0000000000..55fa03d4ee
--- /dev/null
+++ b/files/es/web/css/max-width/index.html
@@ -0,0 +1,158 @@
+---
+title: max-width
+slug: Web/CSS/max-width
+tags:
+ - Referencia_CSS
+translation_of: Web/CSS/max-width
+---
+<div>{{CSSRef}}</div>
+
+<p>The <strong><code>max-width</code></strong> <a href="/en-US/docs/CSS">CSS</a> property sets the maximum width of an element. It prevents the <a href="/en-US/docs/Web/CSS/used_value">used value</a> of the {{ Cssxref("width") }} property from becoming larger than the value specified by <code>max-width</code>.</p>
+
+<pre class="brush:css no-line-numbers">/* &lt;length&gt; value */
+max-width: 3.5em;
+
+/* &lt;percentage&gt; value */
+max-width: 75%;
+
+/* Keyword values */
+max-width: none;
+max-width: max-content;
+max-width: min-content;
+max-width: fit-content;
+max-width: fill-available;
+
+/* Global values */
+max-width: inherit;
+max-width: initial;
+max-width: unset;
+</pre>
+
+<p>{{ Cssxref("max-width") }} overrides {{cssxref("width")}}, but {{ Cssxref("min-width") }} overrides {{ Cssxref("max-width") }}.</p>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<h3 id="Values">Values</h3>
+
+<dl>
+ <dt>{{cssxref("&lt;length&gt;")}}</dt>
+ <dd>The maximum width, expressed as a {{cssxref("&lt;length&gt;")}}.</dd>
+ <dt>{{cssxref("&lt;percentage&gt;")}}</dt>
+ <dd>The maximum width, expressed as a {{cssxref("&lt;percentage&gt;")}} of the containing block's width.</dd>
+</dl>
+
+<h4 id="Keyword_values">Keyword values</h4>
+
+<dl>
+ <dt><code>none</code></dt>
+ <dd>The width has no maximum value.</dd>
+ <dt><code>max-content</code>{{experimental_inline()}}</dt>
+ <dd>The intrinsic preferred width.</dd>
+ <dt><code>min-content</code>{{experimental_inline()}}</dt>
+ <dd>The intrinsic minimum width.</dd>
+ <dt><code>fill-available</code>{{experimental_inline()}}</dt>
+ <dd>The containing block's width minus the horizontal margin, border, and padding. (Note that some browsers implement an ancient name for this keyword, <code>available</code>.)</dd>
+ <dt><code>fit-content</code>{{experimental_inline()}}</dt>
+ <dd>The same as <code>max-content.</code></dd>
+</dl>
+
+<h3 id="Formal_syntax">Formal syntax</h3>
+
+<pre class="syntaxbox">{{csssyntax}}</pre>
+
+<h2 id="Examples">Examples</h2>
+
+<p>In this example, the "child" will be either 150 pixels wide or the width of the "parent," whichever is smaller:</p>
+
+<div id="basic-max-width-demo">
+<pre class="brush: html">&lt;div id="parent"&gt;
+ &lt;div id="child"&gt;
+ Fusce pulvinar vestibulum eros, sed luctus ex lobortis quis.
+ &lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">#parent {
+ background: lightblue;
+ width: 300px;
+}
+
+#child {
+ background: gold;
+ width: 100%;
+ max-width: 150px;
+}
+</pre>
+</div>
+
+<p>{{EmbedLiveSample("basic-max-width-demo", 350, 100)}}</p>
+
+<p>The <code>fit-content</code> value can be used to set the width of an element based on the intrinsic size required by its content:</p>
+
+<div id="fit-content-demo">
+<pre class="brush: html" style="display: none;">&lt;div id="parent"&gt;
+ &lt;div id="child"&gt;
+ Child Text
+ &lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">#parent {
+ background: lightblue;
+ width: 300px;
+}
+
+#child {
+ background: gold;
+ width: 100%;
+ max-width: -moz-fit-content;
+ max-width: -webkit-fit-content;
+}
+</pre>
+</div>
+
+<p>{{EmbedLiveSample("fit-content-demo", 400, 100)}}</p>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{ SpecName('CSS3 Sizing', '#width-height-keywords', 'max-width') }}</td>
+ <td>{{ Spec2('CSS3 Sizing') }}</td>
+ <td>Adds the <code>max-content</code>, <code>min-content</code>, <code>fit-content</code>, and <code>fill-available</code> keywords.<em> </em>(Both CSS3 Box and CSS3 Writing Modes drafts used to define these keywords, but are superseded by this spec.<em>)</em></td>
+ </tr>
+ <tr>
+ <td>{{ SpecName('CSS3 Transitions', '#animatable-css', 'max-width') }}</td>
+ <td>{{ Spec2('CSS3 Transitions') }}</td>
+ <td>Defines <code>max-width</code> as animatable.</td>
+ </tr>
+ <tr>
+ <td>{{ SpecName('CSS2.1', 'visudet.html#min-max-widths', 'max-width') }}</td>
+ <td>{{ Spec2('CSS2.1') }}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_Compatibility" name="Browser_Compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("css.properties.max-width")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{ Cssxref("width") }}, {{ Cssxref("min-width") }}, {{ Cssxref("max-height") }}</li>
+ <li><a href="/en/CSS/box_model" title="en/CSS/box_model">The box model</a>, {{ Cssxref("box-sizing") }}</li>
+</ul>