一般有两种写法,第一种是分开写的,比如:
body{
background-image:url('这里是图片路径'); /*加载图片*/
background-color:#fff; /*设置颜色,这里可以16进制的颜色,也可以常用的颜色单词*/
background-repeat:repeat;/*设置平铺方式,repeat就是从左到右,从上到下平铺;repeat-x:从左往右平铺;repeat-y:从上往下平铺;不平铺no-repeat*/
background-position:left top;/*设置图片位置,left top指左上对齐;还有left bottom;right top;right bottom;center top;center bottom;center center;left center;right center;*/
/*background-size是CSS3常用的属性*/
}
第二种是链式写法,比如:
body{background:#fff url('图片路径') no-repeat left top;}
个人比较常用的是第二种方式,看哪种方式更适合你,就使用哪种方式。