CSS Reference Manual
How to set all background properties in one declaration:
body { background: #00FF00 url(bgimage.gif) no-repeat fixed top; }
Try it yourself
All browsers support the background attribute.
Note: IE8 and earlier browsers do not support multiple background images for one element.
Note: IE7 and earlier browsers do not support "inherit". IE8 requires !DOCTYPE. IE9 supports "inherit".
Background shorthand property sets all background properties in one declaration.
You can set the following properties:
If one of the values is not set, it will not There will be problems, such as background:#ff0000 url('smiley.gif'); is also allowed.
It is generally recommended to use this attribute rather than using individual attributes individually, as it is better supported in older browsers and requires fewer letters to be typed.
not specified |
no |
CSS1 CSS3 |
object.style.background="white url(paper.gif) repeat-y" |
background-color | 规定要使用的背景颜色。 | 1 |
background-position | 规定背景图像的位置。 | 1 |
background-size | 规定背景图片的尺寸。 | 3 |
background-repeat | 规定如何重复背景图像。 | 1 |
background-origin | 规定背景图片的定位区域。 | 3 |
background-clip | 规定背景的绘制区域。 | 3 |
background-attachment | 规定背景图像是否固定或者随着页面的其余部分滚动。 | 1 |
background-image | 规定要使用的背景图像。 | 1 |
inherit | 规定应该从父元素继承 background 属性的设置。 | 1 |
CSS Tutorial: CSS Background
CSS3 Tutorial: CSS3 Background
HTML DOM Reference Manual: background attribute