如何在滚动时阻止照片的位置发生变化

How to stop a photo's positioning from changing as you scroll

我有一张照片作为登陆页面的背景照片。当我向下滚动时,我希望照片相对于查看者的位置保持不变,但我在执行此操作时遇到了问题。

http://ellensriley.com/#about

例如,在这个人的网站中,即使您滚动并前进到页面的下一部分,女孩的脸也处于相同的位置。非常感谢您的帮助!

使用 CSS background-attachment: fixed (https://developer.mozilla.org/en-US/docs/Web/CSS/background-attachment)

body {
    background: url(mypicture.png) no-repeat;
    background-attachment: fixed;
}

用你的图片路径替换mypicture.png