CSS 背景附件修复在 chrome 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24901474/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:46:02  来源:igfitidea点击:

background-attachment fixed not working in chrome

cssgoogle-chrome

提问by user3718799

I tried google for help on this and it seems to be a bug in chrome but I still can't find a solution. I have taken a look at many stackoverflow questions similar to this but those solutions still didn't help.

我试过谷歌寻求帮助,这似乎是 chrome 中的一个错误,但我仍然找不到解决方案。我查看了许多与此类似的 stackoverflow 问题,但这些解决方案仍然没有帮助。

When I try to scroll down on the page the background-image flickers and messes up. I am using Google Chrome Version 35.0.1916.153 on Ubuntu Desktop

当我尝试在页面上向下滚动时,背景图像闪烁并混乱。我在 Ubuntu 桌面上使用 Google Chrome 版本 35.0.1916.153

CSS code:

CSS代码:

#left-container {
background-image: url('http://easource.com/wp-content/uploads/2014/07/traphouse4.jpg');
background-attachment: fixed;
background-position: -1% 0%;
background-repeat: repeat-y;
cursor: pointer;
}

You can see how it looks on http://easource.com

您可以在http://easource.com上查看它的外观

Also, I tried removing the background-position but still doesn't work.

另外,我尝试删除背景位置,但仍然无效。

回答by Dimas Pante

回答by Digggid

You can keep your position as is and add the transform property to your background image element.

您可以保持原样并将变换属性添加到背景图像元素。

transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);

回答by Cristian Oana

Try adding backface-visibility: hidden;. Worked for me.

尝试添加backface-visibility: hidden;. 为我工作。

回答by Joe Bauer

Removing overflow-y: scroll;from bodysolved the issue for me.

删除overflow-y: scroll;body解决问题的我。

回答by SMP Design Media

It's working fine with using position:static;
if it doesn't work, remove the positionproperty.

使用它可以正常工作position:static
如果它不起作用,请删除该position属性。