HTML代码

1
<div class="bjimg"></div>

CSS代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
.bjimg {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
min-width: 1000px;
z-index: -10;
zoom: 1;
background-color: #fff;
background-image: url(../static/images/background.png);
background-repeat: no-repeat;
background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
background-position: center 0;
}

PS.

来源:给网页添加背景图片 html+css_北极光之夜。-CSDN博客