CSS background-position Property

❮ Previous Reference Next ❯

Example

body { 
  background-image: url("smiley.png");
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-position: center; 
}

Keyword values:

Percentage values:

Length values:

Multiple images:

Edge offsets values:

Global values:



Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Lorem Ipsum is simply dummy text of the printing and typesetting industry.


Meaning

The background-position CSS property sets the initial position for each background image. The position is relative to the position layer set by background-origin.

The background-position properties of the shorthand:

Default value:0% 0%
Inherited:No
Animatable:Yes
Version:CSS1
JavaScript syntax:
object.style.backgroundPosition="[ percentage | length | left | center | right ]1 or 2 values | initial | inherit|revert|revert-layer|unset";



Standard Syntax

background-position: [ percentage | length | left | center | right ]1 or 2 values | initial | inherit|revert|revert-layer|unset;



Browser Support

The numbers in the table specify the first browser version that fully supports the property.




Status







Property Values

The following table describes the values of this property.

Value Description
bottom Equivalent to 100% for the vertical position.
center Equivalent to 50% for the horizontal position if it is not otherwise given, or 50% for the vertical position if it is.
left Equivalent to 0% for the horizontal position.
right Equivalent to 100% for the horizontal position.
top Equivalent to 0% for the vertical position.
length Actual pixel lengths. For example, with a value pair of '10px 20px', the upper left corner of the image is placed 10px to the right and 20px below the upper left corner of the element's box.
percentage A percent of the element size. For example, with a value pair of '0% 0%', the upper left corner of the image is aligned with the upper left corner of the element's box.
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: 0% 0%;
}
❮ Previous Reference Next ❯