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);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM