手机背景图片自适应浏览器屏幕大小,完全填满

通用:

<div id="formbackground" style="position:absolute; width:100%; height:100%; z-index:-1">
<img src="pictures/background.jpg" height="100%" width="100%"/>
</div>

 

引用jquery:

<div id="formbackground" style="position:absolute; z-index:-1;"><img src="10.jpg" height="100%" width="100%"/></div>
<script type="text/javascript">
$(function(){
$('#formbackground').height($(window).height());
$('#formbackground').width($(window).width());
});
</script>

 

兼容火狐、谷歌和IE浏览器:

.bg{
background:url(http://wyz.67ge.com/wp-content/uploads/qzlogo.jpg);
filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale')";
-moz-background-size:100% 100%;
-webkit-background-size:100% 100%;
background-size:100% 100%;
}

 

背景图铺满整个页面:background-size: cover;

body {

background:"images\001.png"
background-repeat:no-repeat ;
background-size:100% 100%;
background-attachment: fixed;
}

posted @ 2016-12-02 15:20  薄小冰  阅读(7940)  评论(0编辑  收藏  举报