background-attachment fixed with transform not wor

2020-02-01 17:56发布

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.

3条回答
相关推荐>>
2楼-- · 2020-02-01 18:43

This has been solved in this question.

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

查看更多
我想做一个坏孩纸
3楼-- · 2020-02-01 18:44

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

查看更多
男人必须洒脱
4楼-- · 2020-02-01 18:49

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.

查看更多
登录 后发表回答