background的子属性顺序为:
background-color,background-image,background-repeat,background-attachment,background-position,background-size。
实际应用中,我们可以用background属性将上面所有的设置项放在一起,而且也建议这么做,这样做性能更高,而且兼容性更好。比如:
background:lightblue url(w3.png) no-repeat center fixed
“lightblue” 是设置background-color;
“url(w3.png)” 是设置background-image;
“no-repeat” 是设置background-repeat;
“center” 是设置background-position;
“fixed” 是设置background-attachment,
各个设置项用空格隔开,有的设置项不写也是可以的,它会使用默认值。