当 background-attachment: fixed;
与 position: absolute;
结合使用时,视差滚动效果会反转或进入错误的方向。当未应用 position: absolute;
时效果很好。
请参阅此代码笔:https://codepen.io/0xbbadbeef/pen/bKaYQp
.attached-abs {
width: 100%;
height: 200px;
background-image: url('https://thetypewritermovie.files.wordpress.com/2011/06/shaw2.png');
background-attachment: fixed;
position: absolute;
}
同样的 CSS 在 Edge 上运行良好,但无法在 Chrome 上运行。
我是否使用了错误的属性或有任何解决方法?
最佳答案
您可以尝试将位置设置为相对position:relative;
希望对你有帮助
干杯!
关于html - '背景附件: fixed' breaks when 'position: absolute' is used on chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50920013/