我在我的网站上有视差效果,但在滚动时它似乎相当跳跃如下:
这是代码:
jQuery(document).ready(function() {
jQuery(window).scroll(function() {
jQuery('*[class^="prlx"]').each(function(r) {
var pos = $(this).offset().top;
var scrolled = $(window).scrollTop();
jQuery('*[class^="prlx"]').css('top', +(scrolled * 0.6) + 'px');
});
});
});
*[class^="prlx"] {
position: absolute;
width: 100%;
height: 300%;
top: 0;
left: 0;
z-index: -1;
background-size: 110%;
}
.prlx-2 {
background-image: url('http://www.roscodigitalmedia.co.uk/rosco/wp-content/uploads/2015/12/bigstock-Artist-Photographer-Retouches-91840682.jpg');
}