May 05, 2021 CSS Reference Manual
Background abbreviated properties can set all background properties in one declaration.
The properties that can be set are: background-color, background-position, background-size, background-repeat, background-origin, background-clip, background-attachment, and background-image.
If one of the above values is missing, it doesn't matter, #FF0000 background: .gif); is allowed.
Default: | See separate properties |
---|---|
Inherited: | no |
Version: | The new property in CSS1 plus CSS3 |
JavaScript syntax: | object object.style.background="red url(smiley.gif) top left no-repeat" |
Value | Description | Css |
---|---|---|
background-color | Specify the background color to use | 1 |
background-position | Specify the location of the background image | 1 |
background-size | Specify the size of the background picture | 3 |
background-repeat | Specify how to repeat the background image | 1 |
background-origin | Specifies the positioning area of the background image | 3 |
background-clip | Specifies the painting area of the background image | 3 |
background-attachment | Set whether the background image is fixed or scrolls with the rest of the page. | 1 |
background-image | Specify one or more background images to use | 1 |
Set multiple background images in one div element (and specify their location):
The numbers in the table support the first browser version number of the property.
The number immediately before -webkit-, -ms- or -moz- is the first browser version number that supports the prefix property.
Attributes | |||||
---|---|---|---|---|---|
background | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Background properties are supported by all major browsers.
Note IE8 and earlier versions do not support multiple background images for an element.
Note I E7 and earlier versions do not support "inherited" values. I E8 needs to be defined! D OCTYPE。 IE9 supports inheritance.
CSS tutorial: CSS Background
CSS3 tutorial: CSS3 Backgrounds