CSS background-position-x Property

❮ Previous Reference Next ❯

Example

div {
  width: 300px;
  height: 300px;
  background-color: red;
  background-image: url("fox.png");
  background-repeat: no-repeat;
  background-position-x: center;
}






Meaning:

The background-position-x CSS property specifies the initial horizontal position for each background image.

The position is relative to the position layer set by background-origin.

Default value:0%
Inherited:No
Animatable:Discrete
Version:CSS3
JavaScript syntax:
object.style.backgroundPositionX="left|center|right|length|percentage|initial|inherit|revert|revert-layer|unset";



Standard Syntax

background-position-x: left|center|right|length|percentage|initial|inherit|revert|revert-layer|unset;



Browser Support




Status







Property Values

The following table describes the values of this property.

Value Description
left Aligns the left edge of the background image with the left edge of the background position layer.
center Aligns the center of the background image with the center of the background position layer.
right Aligns the right edge of the background image with the right edge of the background position layer.
length 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).
percentage 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 right edge of the background image is aligned with the right edge of the container, thus a value of 50% horizontally centers the background image.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-delay property.
revert Reverts the cascaded value of the property from its current value to the value the property
revert-layer Rollback styles to the ones specified in previous cascade layers.
unset Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.



Default CSS Property Values

selectors {
  background-position-x: 0%;
}
❮ Previous Reference Next ❯