我目前正在做一个视差网站主题.对于某些'div'和'section,需要将背景图像附加为固定的,以避免jquery沉迷于所有内容.问题是任何动画项目下方标签的背景图像在转换完成时消失,仅在Google Chrome上.补救?
我有一个具有固定背景的滚动元素:
.my-element {
background: url(/foo.png) no-repeat right bottom;
background-attachment: fixed;
}
Run Code Online (Sandbox Code Playgroud)
效果很好!通常情况下。但是,如果我对其应用平移变换(即使是 0)(我需要动画),背景就会变为非固定(它锚定到 .my-element 的底部,该元素滚动到视图之外) :
.my-element {
background: url(/foo.png) no-repeat right bottom;
background-attachment: fixed;
transform: translateX(0); // this breaks the "fixed" behavior
}
Run Code Online (Sandbox Code Playgroud)
这里有一个类似的问题,但 4 年前的答案说这个错误已经被修复,而且只有 Firefox 才有。我在 Firefox 和 Chrome 中就遇到了这种情况。
有什么办法可以避免这种情况吗?或者有没有办法在没有背景附件属性的情况下获得相同的行为?谢谢!
编辑:刚刚添加了一个 jsfiddle 来演示该问题:https ://jsfiddle.net/mozges0k/7/