English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
CSS background-The position property sets the element'sbackground-imageThe initial position (i.e., the origin). Use the shorthandBackgroundProperties are usually more convenient.
The following table summarizes the usage context and version history of this property.
Default value: | 0% 0% |
---|---|
Applies to: | All elements |
Inheritance: | None |
Animatable: | Yes.Please refer to Animation properties. |
Version: | CSS 1,2,3 |
JavaScript syntax: | object object.style.backgroundPosition="center" |
Syntax of position usage
background-The syntax of this attribute is as follows: 1 position: [ percentage | length | left | center | right ] 2 or
values | initial | inherit-The following example demonstrates how to use background
Example background-p {/image: url("images background-smiley.png"); 5position: 0% center;}/Test and see‹
›Note:
Attribute value
The following table describes the values of this attribute. | Value |
---|---|
Description | bottom10Is equivalent to the horizontal position |
Is equivalent to the vertical position | center5If not otherwise specified, it is equal to the horizontal position5Is equivalent to the horizontal position |
0%, otherwise provide the vertical position | left |
Is equivalent to 0% of the horizontal position. | right10Is equivalent to the horizontal position |
0%. | top |
The vertical position is equal to 0%. | length 10Actual pixel length. For example, using the value pair ' 2px10px, while the top left corner of the image is below the top left corner of the box20px. |
percentage | Percentage of the element size. For example, using the value pair '0% 0%', the top left corner of the image aligns with the top left corner of the element box. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated elements adopt the computed value of the background attribute of its parent element-position. |
background-Browser compatibility of the position attribute, all major browsers support this attribute.
|
Please refer to the following tutorials:CSS background,CSS3Background.
Related attributes:background,background-attachment,background-color,background-clip,background-image,background-origin,background-repeat,background-size.