The background
shorthand CSS property sets all background style properties at once, such as background-clip
,background-color
,background-image
,background-origin
,background-position
,background-repeat
,background-size
.
The background property is specified as one or more background layers, separated by commas.
The syntax of each layer is as follows:
<bg-image>
<position>
<bg-size>
<repeat-style>
<bg-size>
value may only be included immediately after <position>
, separated with the '/' character, like this: "center/80%"
.<box>
value may be included zero, one, or two times. If included once, it sets both background-origin
and background-clip
. If it is included twice, the first occurrence sets background-origin
, and the second sets background-clip
.The
background-color
value may only be included in the last layer specified.
<box>
See background-clip
and background-origin
<background-color>
See background-color
<bg-image>
See background-image
<position>
<repeat-style>
<bg-size>
See background-size
background: red url('./a.png'), url('./b.png);'
will be ignored as an error.
The correct way to write it should be: background: url('./a.png'),red url('./b.png);
Initial value | background-image: none background-position: 0% 0% background-size: auto auto background-repeat: repeat background-origin: padding-box background-clip: border-box background-color: transparent |
Applies to | all elements |
Inherited | no |
Animatable | no |
<bg-layer>
does not support the <attachment>
<image>
only support <url>
and <gradient>
_These properties are also supported in web such as
<image-set>
、<element()>
、<paint()>
、<cross-fade()>
_
<gradient>
only support <linear-gradient>
and <radial-gradient>
These properties are also supported in web such as
<repeating-linear-gradient()>
,<radial-gradient()>
,<repeating-radial-gradient()>
,<conic-gradient()>
LCD tables only load in the browser