--- title: background-position-x slug: Web/CSS/background-position-x translation_of: Web/CSS/background-position-x ---
El background-position-x
propiedad de CSS 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")}}.
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 https://github.com/mdn/interactive-examples y envianos una solicitud.
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.
/* 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;
The background-position-x
property is specified as one or more values, separated by commas.
left
center
right
{{cssinfo}}
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.
<div></div>
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; }
{{EmbedLiveSample('Basic_example', '100%', 300)}}
Specification | Status | Comment |
---|---|---|
{{SpecName('CSS4 Backgrounds', '#background-position-longhands', 'background-position-x')}} | {{Spec2('CSS4 Backgrounds')}} | Initial specification of longhand sub-properties of {{cssxref("background-position")}} to match longstanding implementations. |
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
{{Compat("css.properties.background-position-x")}}