背景图片全屏覆盖并居中显示
第一种:
HTML:
<body>
<section class="background">
<img src="bg.jpg">
</section>
</body>
CSS:
.background{
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: -1;
}
.background>img{
height: 100%;
width: 100%;
border: 0;
}
第二种只在CSS中设置
body{
background-image:
url(../html/bgimg.jpg);
background-repeat: no-repeat;
background-size:
100
%;
}