Property Description
The background-position property sets the starting position of a background image.
This property has the following syntax:
background-position: left|right|center top|center|bottom|initial|inherit;
background-position: x% y%|initial|inherit;
background-position: xpos ypos|initial|inherit;
Property Values
Value | Description |
---|---|
left top
left center left bottom right top right center right bottom center top center center center bottom |
The starting position of the background image.
Note: If only one keyword is specified, the second value will be "center" |
x% y% | (default: 0% 0%) The first value is the horizontal position and the second value is the vertical. The top, left corner is 0% 0% and the bottom, right corner is 100% 100%.
Note: If only one value is specified, the second value will be "50%" |
xpos ypos | The first value is the horizontal position and the second value is the vertical position. The top, left corner is 0 0.
Note: If only one value is specified, the second value will be "50%" |
initial | Specifies that the value of the property should be set to the default value |
inherit | Specifies that the value of the property should be inherited from the parent element |
Examples
This example shows how to specify the position of a background-image.
body {
background-image:url('bg-image.gif');
background-repeat:no-repeat;
background-attachment:fixed;
background-position:center;
}
Browser Support
Note:For Firefox and Opera, the background-attachment property must be set to "fixed".
Chrome | Firefox | IE | Opera | Safari |
---|---|---|---|---|
1.0 | 1.0 | 4.0 | 1.0 | 3.5 |
Miscellaneous Information
Inherited: | No |
---|---|
Defined In: | CSS1 |
Default Value: | 0% 0% |