I have encountered a parallax effect issue while working on this site with pictures. The problem is that the pictures are getting clipped, and I need to figure out how to fix this issue. When I scroll down to a certain length, it cuts off the pictures and transitions to the next one abruptly, causing the previous picture to overlap. It's disorienting because when you reach the bottom picture, it shows up at the top and vice versa.
Check out jQuery Parallax for more details.
<section class="home">
<div class="pic img1 parallax"></div>
<div class="pic img2 parallax"></div>
<div class="pic img3 parallax"></div>
<div class="pic img4 parallax"></div>
</section>
body {
box-sizing: border-box;
margin: 0;
}
section {
width: 100%;
height: 50em;
}
.pic {
width: 100%;
height: 50em;
background-size: cover;
background-position: center;
}
.img1 {
background-image: url('https://images.unsplash.com/photo-1536164832230-6c238c58f740?ixlib=rb-0.3.5&s=09987436d4a89cf8c848c93aa574dfda&auto=format&fit=crop&w=1650&q=80');
}
.img2 {
background-image: url('https://images.unsplash.com/photo-1536221236547-04007cfc3d8b?ixlib=rb-0.3.5&s=426505fd76bd618fdd95640f8870e38c&auto=format&fit=crop&w=1650&q=80');
}
.img3 {
background-image: url('https://images.unsplash.com/photo-1536171010494-d89014448ca1?ixlib=rb-0.3.5&s=4f7b5d0b81a5f1e1445a86fd9a251a46&auto=format&fit=crop&w=1576&q=80');
}
.img4 {
background-image: url('https://images.unsplash.com/photo-1536108978996-128e3e2a9783?ixlib=rb-0.3.5&s=31ce21b0ec2bb391c601c681fc1c7952&auto=format&fit=crop&w=1475&q=80');
}
//jQuery Parallax
$(document).ready(function() {
$(window).scroll(function() {
parallax();
})
function parallax() {
var wScroll = $(window).scrollTop();
//select element, class, id etc and property
$('.pic').css('background-position', 'center ' +(wScroll)+'px')
//you can also change speed
}
});