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