diff options
Diffstat (limited to 'files/es/web/css/background-position-x/index.html')
-rw-r--r-- | files/es/web/css/background-position-x/index.html | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/files/es/web/css/background-position-x/index.html b/files/es/web/css/background-position-x/index.html new file mode 100644 index 0000000000..cb85bcd824 --- /dev/null +++ b/files/es/web/css/background-position-x/index.html @@ -0,0 +1,128 @@ +--- +title: background-position-x +slug: Web/CSS/background-position-x +translation_of: Web/CSS/background-position-x +--- +<div>{{CSSRef}}</div> + +<p>El <strong><code>background-position-x</code></strong> propiedad de <a href="/en-US/docs/Web/CSS">CSS</a> coloca la posicion horizontal inicial por cada imagen de fondo. La posicion es relativa a la posicion de la capa puesta por {{cssxref("background-origin")}}.</p> + +<div>{{EmbedInteractiveExample("pages/css/background-position-x.html")}}</div> + +<p class="hidden">El recurso para este ejemplo interactivo es almacenado en un repositorio GitHub. Si te gustaría contrubuir al proyecto de ejemplos interactivos, por favor clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> y envianos una solicitud.</p> + +<p>The value of this property is overridden by any declaration of the {{cssxref("background")}} or {{cssxref("background-position")}} shorthand properties applied to the element after it.</p> + +<h2 id="Syntax" name="Syntax">Syntax</h2> + +<pre class="brush: css no-line-numbers notranslate">/* Keyword values */ +background-position-x: left; +background-position-x: center; +background-position-x: right; + +/* <percentage> values */ +background-position-x: 25%; + +/* <length> values */ +background-position-x: 0px; +background-position-x: 1cm; +background-position-x: 8em; + +/* Side-relative values */ +background-position-x: right 3px; +background-position-x: left 25%; + +/* Multiple values */ +background-position-x: 0px, center; + +/* Global values */ +background-position-x: inherit; +background-position-x: initial; +background-position-x: unset; +</pre> + +<p>The <code>background-position-x</code> property is specified as one or more values, separated by commas.</p> + +<h3 id="Values">Values</h3> + +<dl> + <dt><code>left</code></dt> + <dd>Aligns the left edge of the background image with the left edge of the background position layer.</dd> + <dt><code>center</code></dt> + <dd>Aligns the center of the background image with the center of the background position layer.</dd> + <dt><code>right</code></dt> + <dd>Aligns the right edge of the background image with the right edge of the background position layer.</dd> + <dt>{{cssxref("<length>")}}</dt> + <dd>The offset of the given background image's left vertical edge from the background position layer's left vertical edge. (Some browsers allow assigning the right edge for offset).</dd> + <dt>{{cssxref("<percentage>")}}</dt> + <dd>The offset of the given background image's horizontal position relative to the container. A value of 0% means that the left edge of the background image is aligned with the left edge of the container, and a value of 100% means that the <em>right</em> edge of the background image is aligned with the <em>right</em> edge of the container, thus a value of 50% horizontally centers the background image.</dd> +</dl> + +<h2 id="Formal_definition">Formal definition</h2> + +<p>{{cssinfo}}</p> + +<h2 id="Formal_syntax">Formal syntax</h2> + +<pre class="syntaxbox notranslate">{{csssyntax}}</pre> + +<h2 id="Examples">Examples</h2> + +<h3 id="Basic_example">Basic example</h3> + +<p>The following example shows a simple background image implementation, with background-position-x and background-position-y used to define the image's horizontal and vertical positions separately.</p> + +<h4 id="HTML">HTML</h4> + +<pre class="brush: html notranslate"><div></div></pre> + +<h4 id="CSS">CSS</h4> + +<pre class="brush: css notranslate">div { + width: 300px; + height: 300px; + background-color: skyblue; + background-image: url(https://media.prod.mdn.mozit.cloud/attachments/2020/07/29/17350/3b4892b7e820122ac6dd7678891d4507/firefox.png); + background-repeat: no-repeat; + background-position-x: center; + background-position-y: bottom 10px; +}</pre> + +<h4 id="Result">Result</h4> + +<p>{{EmbedLiveSample('Basic_example', '100%', 300)}}</p> + +<h2 id="Specifications" name="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('CSS4 Backgrounds', '#background-position-longhands', 'background-position-x')}}</td> + <td>{{Spec2('CSS4 Backgrounds')}}</td> + <td>Initial specification of longhand sub-properties of {{cssxref("background-position")}} to match longstanding implementations.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("css.properties.background-position-x")}}</p> + +<h2 id="See_also" name="See_also">See also</h2> + +<ul> + <li>{{cssxref("background-position")}}</li> + <li>{{cssxref("background-position-y")}}</li> + <li>{{cssxref("background-position-inline")}}</li> + <li>{{cssxref("background-position-block")}}</li> + <li><a href="/en-US/docs/CSS/Multiple_backgrounds" title="CSS/Multiple backgrounds">Using multiple backgrounds</a></li> +</ul> |