定义和用法
background 简写属性在一个声明中设置所有的背景属性。
可以设置如下属性:
background-color
background-position
background-size
background-repeat
background-origin
background-clip
background-attachment
background-image
如果不设置其中的某个值,也不会出问题,比如 background:#ff0000 url('smiley.gif')也是允许的。
通常建议使用这个属性,而不是分别使用单个属性,因为这个属性在较老的浏览器中能够得到更好的支持,而且需要键入的字母也更少。
默认值:
not specified继承性:
no版本:
CSS1 + CSS3JavaScript 语法:
object.style.background="white url(paper.gif) repeat-y"实例
如何在一个声明中设置所有背景属性:
body{
background: #00FF00 url(bgimage.gif) no-repeat fixed top
}
CSS3中的background-origin属性值为:
padding-box:背景图像相对于内边距框来定位。
border-box:背景图像相对于边框盒来定位。
content-box:背景图像相对于内容框来定位。