-
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
- A position defines an x/y coordinate, to place an item relative to the edges of an element's box.
- It can be defined using one to four values
-
If two non-keyword values are used, the first value represents the
horizontal
position and the second represents thevertical
position -
If only one value is specified, the second value is assumed to be
center
- If three or four values are used, the length-percentage values are offsets for the preceding keyword value(s)
-
If two non-keyword values are used, the first value represents the
-
1-value syntax
- The keyword value center, which centers the image
-
One of the keyword values
top
left
bottom
right
-
A
length
orpercentage
. This specifies theX coordinate
relative to the left edge, with theY coordinate set to 50%
-
2-value syntax
One value defines X and the other defines Y. Each value may be:- One of the keyword values
top
left
bottom
right
-
If
left
orright
is given, then this definesX
and the other given value definesY
-
If
top
orbottom
is given, then this definesY
and the other value definesX
- Note that:
-
If one value is
top
orbottom
, then the other value may not betop
orbottom
- If one value is left or right, then the other value may not be left or right
-
If one value is
- One of the keyword values
3-value syntax
Two values are keyword values, and the third is the offset for the preceding value-
4-value syntax
- The first and third values are keyword values defining X and Y
- The second and fourth values are offsets for the preceding X and Y keyword values