Syntax | selector {background-position: value1 value2;}
(OR)
selector {background-position: value1 value2;}
(OR)
selector {background-position: value;}
|
---|---|
Usage | The background-position property is used to specify the initial position of the background image. If only one value is specified then the other value is assumed to be the keyword center. This property is specified by using percentage, length, and keyword values according to the syntax shown above. If a percentage or length is used, then the first value represents the horizontal position and the second value the vertical position. Negative values are permitted for both percentage and length values.
CSS Example: The background-position property is set using a keyword for the horizontal position and a percentage for the vertical position. body {background-position: right 25%;
background-image: url("../images/floatingball.gif");
background-repeat: no-repeat;
background-color: yellow;
} CSS Example: The background-position property is set using only a single keyword for the vertical position. The horizontal position will default to the keyword "center." body {background-position: bottom;
background-image: url("../images/floatingball.gif");
background-repeat: no-repeat;
background-color: yellow;
} CSS Example: The background-position property is set using a length for the horizontal and vertical position. body {background-position: 50px 20px;
background-image: url("../images/floatingball.gif");
background-repeat: no-repeat;
background-color: yellow;
} CSS Example: The background-position property is set to the top left corner using keywords for the horizontal and vertical position. The image is set to repeat. body {background-position: left top;
background-image: url("../images/floatingball.gif");
background-repeat: repeat;
background-color: yellow;
} |
Keywords |
|
Applies To | All elements |
Inherited | No |
Initial Value | 0% 0% |