每个页面上都有相同的背景图片
如果你想要一个调整大小并填充整个窗口空间的背景图像,无论大小如何,那么使用这个CSS,
html {
background: url(images/bg.jpg) no-repeat center center fixed;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
每个页面上的不同背景图像
如果您想为每个页面选择不同的背景图片,
HTML
CSS
#bg {
position:fixed;
top:-50%;
left:-50%;
width:200%;
height:200%;
}
#bg img {
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
margin:auto;
min-width:50%;
min-height:50%;
}