I've been trying for hours how to fix a bug that is happening only on chrome
.
There are 2 layers in a wrapper, which are:
- Parallax background
- Normal content scrolled
i've been doing parallax effect by using translateZ
and scale
rules, everything works fine on firefox.. but for some reason which i don't know, on chrome
it makes the parent wrapper to take a huge size to fit with the scale from the parallax background.
many posts say that this issue can be fixed by adding translateZ(0)
or z-index: 0
to the wrapper but yet it doesn't fix my issue. So the code on CSS for parallax looks like this:
#parallax {
perspective: 1px;
height: 100vh;
overflow-x: hidden;
overflow-y: auto;
}
.parallax__layer {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.parallax__layer--base {
transform: translateZ(0);
}
#parallax__layer--back {
transform: translateZ(-50px) scale(56);
background: url("/assets/images/background.jpg");
background-repeat: no-repeat;
background-size: 100% 100%;
background-attachment: fixed;
background-position: center;
scroll-behavior: smooth;
}
HTML where parallax should be positioned:
<body>
<div id="parallax">
<div id="parallax__layer--back" class="parallax__layer "></div>
<div class="parallax__layer parallax__layer--base">
<!-- Base Content -->
</div>
</div>
</body>