Html 背景图像滚动

Html 背景图像滚动,html,css,Html,Css,我的背景代码是: body{ background:url(pics/bg.jpg)no-repeat center center;background-size:cover;} } 问题是,当我向下滚动页面时,图像会滚动,我不需要它:请帮助您需要背景附件:修复问题是您没有使用背景附件:修复。 有两种方法可以做到这一点: body{background:url(pics/bg.png)no-repeat center cente

我的背景代码是:

    body{

       background:url(pics/bg.jpg)no-repeat center center;background-size:cover;}

                   }

问题是,当我向下滚动页面时,图像会滚动,我不需要它:请帮助您需要
背景附件:修复
问题是您没有使用背景附件:修复。
有两种方法可以做到这一点:

 body{background:url(pics/bg.png)no-repeat center center fixed;}


您需要添加背景附件:固定;然后删除一个}如下所示:

body {
   background:url(pics/bg.jpg)no-repeat center center;
   background-size:cover;
   background-attachment: fixed;
  }
body {
   background:url(pics/bg.jpg)no-repeat center center;
   background-size:cover;
   background-attachment: fixed;
  }