在css文档里直接改动body.
body{
background-image: url(../images/bg.jpg); /*背景图片路径设置*/
background-repeat:no-repeat; /*不进行平铺,图片适应窗口大小*/
background-attachment: fixed; /*背景图片固定,不随内容滚动*/
background-origin: border-box; /*从边框区域显示*/
background-size:cover;/*全部覆盖*/
}
注意:这里关于背景图路径正确的认为和写法为../images/xx.jpg”。
其中 ../ 表示的是上一级目录,不要写成 ./ 这是表示当前目录。