background:[ background-image ] || [ background-repeat ] || [ background-attachment ] || [ background-position ]
相关属性:[ background-origin ] || [ background-clip ] || [ background-size ]
缩写方式:
background:url(test1.jpg) no-repeat scroll 10px 20px,url(test2.jpg) no-repeat scroll 50px 60px,url(test3.jpg) no-repeat scroll 90px 100px; background-origin:content-box,content-box,content-box; background-clip:padding-box,padding-box,padding-box; background-size:50px 60px,50px 60px,50px 60px;
拆分方式:
background-image:url(test1.jpg),url(test2.jpg),url(test3.jpg); background-repeat:no-repeat,no-repeat,no-repeat; background-attachment:scroll,scroll,scroll; background-repeat:10px 20px,50px 60px,90px 100px; background-origin:content-box,content-box,content-box; background-clip:padding-box,padding-box,padding-box; background-size:50px 60px,50px 60px,50px 60px;
如果定义了多个背景图片,而其他属性只有一个参数值,则表明所有背景图片的该属性都应用同一个参数值。据此可以对上面的例子进行缩写:
缩写方式:
background:url(test1.jpg) no-repeat scroll 10px 20px,url(test2.jpg) no-repeat scroll 50px 60px,url(test3.jpg) no-repeat scroll 90px 100px; background-origin:content-box; background-clip:padding-box; background-size:50px 60px;
拆分方式:
background-image:url(test1.jpg),url(test2.jpg),url(test3.jpg); background-repeat:no-repeat; background-attachment:scroll; background-repeat:10px 20px,50px 60px,90px 100px; background-origin:content-box; background-clip:padding-box; background-size:50px 60px;
支持版本\类型 | IE | Firefox | Safari | Chrome | Opera |
---|---|---|---|---|---|
版本 | 6.0-8.0 | 4.0 | 5.1 | 13.0 | 11.50 |
版本 | 9.0 |