For a layout such as this: http://codepen.io/anon/pen/dPwQod
HTML:
<div class="fixed-bg one"></div>
<div class="something"></div>
<div class="fixed-bg two"></div>
<div class="something"></div>
<div class="fixed-bg three"></div>
<div class="something"></div>
<div class="fixed-bg four"></div>
<div class="something"></div>
CSS:
.one {
background: url('http://i.imgur.com/gAn5IiK.jpg');
}
.two {
background: url('http://i.imgur.com/dPG6S6o.jpg');
}
.three {
background: url('http://i.imgur.com/rTQcvNZ.jpg');
}
.four {
background: url('http://i.imgur.com/k9aRzrU.jpg');
}
.fixed-bg {
width: 100%;
height: 300px;
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
}
.something {
width: 100%;
height: 200px;
background: black;
}
Chrome repaints the entire viewport on scroll, making the scrolling quite laggy, especially on retina displays. You can view it in action by ticking "Show paint rectangles" in inspector.
I've looked for ways of forcing the backgrounds to individual layers, but found nothing that suits this layout. Some suggest translateZ(0) and putting the background in its own fixed div, but that only works if there is one fixed background. Is there any way to force chrome to not repaint the whole thing on scroll with multiple backgrounds such as this layout? Or at least a way to make this layout possible without the lag in Chrome?
Cheers.