html5中设置整页背景图片的方法是利用css3样式:
写法如下:
img.bg {
/* Set rules to fill background */
min-height: 100%;
min-width: 1024px;
/* Set up proportionate scaling */
width: 100%;
height: auto;
/* Set up positioning */
position: fixed;
top: 0;
left: 0;
}
@media screen and (max-width: 1024px) { /* Specific to this particular image */
img.bg {
left: 50%;
margin-left: -512px; /* 50% */
}
}
效果如:
body{ font-family: "微软雅黑";
width: 100%;
height:auto;
background:url("../img/....png") no-repeat;
background-size: 100%; }
在插入背景图片的容器里设置background-size: 100%,这样图片就会覆盖整页。
在css中设置 background-image: url(../images/bg.jpg) no-repeat;
给body设置样式background:url(你的图片路径)
在body标签里面加style的背景图片url