以body为例,给Body添加已下样式:
body {
// 切记是background,不要写成background-img
// no-repeat 设置图片不平铺 center 设置图片上下垂直居中
background: url(../img/bodybg.jpg) no-repeat center center fixed;
// 以下代码主要是为了处理浏览器兼容性
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover;
}