background-attachment fixed with transform not working in Firefox

女生的网名这么多〃 提交于 2019-11-26 21:59:51

问题


CSS value transform turn off background-attachment: fixed in Firefox.

Here is the example

div {
   transform: translate3d(0,0,0); // if remove starts to work
   width: 100%;
   height: 2000px;
   background-image: url('http://www.wallpapereast.com/static/images/001_Fish-Wallpaper-HD_hkNsK33.jpg');
   background-size: cover;
   background-attachment: fixed;
}
<div></div>

if you remove transform from CSS it starts to work. Reproducible only in FF.


回答1:


background-attachment:fixed; doesn't work when any 'transform' is applied

and that's a bug in firefox and it is not yet fixed.

Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=1292499




回答2:


It was a common problem 2 years ago, but as far as I know, it has been solved a while ago, and now the background-attachment CSS Property is now fully supported by all browsers, according to MDN.




回答3:


This has been solved in this question.

Long story short- use position instead of background-attachment.



来源:https://stackoverflow.com/questions/39633745/background-attachment-fixed-with-transform-not-working-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!