WEB网页如何让背景图片跟随可视窗口自适应大小

HTML代码

<body id="body">
    <div class="info-wrapper">
        <div class="content">
        </div>
     </div>
</div>

CSS代码

body{
  font-size: 16px;
  font-family: Arial;
  max-width: 1920px;
  min-width: 1180px;
  margin:0 auto;
  overflow-y:scroll; 
}

.info-wrapper{
    position: absolute;
    margin: 0px;
    width: 100%;
    height: 560px;
    top: 1563px;
    text-align: center;
}

.content{
    width: 100%;
    height: 560px;
    margin: 0 auto;
    overflow: hidden;
    background: url(../images/index/background.png) no-repeat;
}

JS代码

var screenWidth=$(window).width();
            
$("#body").css("width",screenWidth);

 

posted @ 2017-06-15 21:29  Dreamsqin  阅读(18434)  评论(0编辑  收藏  举报