网页背景图片拉伸

网页背景图片拉伸,方法有很多,但浏览器兼容性好的方法不多。
采用如下css,可以适应从ie6开始的所有浏览器。
<div id="backgroundImage">
   <img src="img/bodybg.jpg" />
</div>
<div id="onbackgroundbody">
</div>

<style>
html{
width:100%;
height:100%;
margin:0;
padding:0;
}
body{
width:100%;
height:100%;
margin:0;
padding:0;
}
#backgroundImage{
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    overflow: hidden;
    z-index: -1;
}
#backgroundImage img{
    width: 100%;
    height: 100%;
}
#onbackgroundbody{
    width: 100%;
    height: 100%;
}
</style>

你可能感兴趣的:(html,UI,css,浏览器)