当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;
希望对你有帮助
干杯!