Jquery 视差滚动无法正常工作
我需要你的视差滚动帮助。 我在这个网站上工作-new.rangafner.com 有两个视差部分-介绍和显示。 介绍工作正常,但节目不正常 出于某种原因,它从中间开始 这是jQuery:Jquery 视差滚动无法正常工作,jquery,css,parallax,Jquery,Css,Parallax,我需要你的视差滚动帮助。 我在这个网站上工作-new.rangafner.com 有两个视差部分-介绍和显示。 介绍工作正常,但节目不正常 出于某种原因,它从中间开始 这是jQuery: $(document).ready(function(){ // cache the window object $window = $(window); $('section[data-type="background"]').each(function(){ // declare the variable
$(document).ready(function(){
// cache the window object
$window = $(window);
$('section[data-type="background"]').each(function(){
// declare the variable to affect the defined data-type
var $scroll = $(this);
$(window).scroll(function() {
// HTML5 proves useful for helping with creating JS functions!
// also, negative value because we're scrolling upwards
var yPos = -($window.scrollTop() / $scroll.data('speed'));
// background position
var coords = '50% '+ yPos + 'px';
// move the background
$scroll.css({ backgroundPosition: coords });
}); // end window scroll
}); // end section function
}); // close out script
这是背景图像的css:
#shows {
background: url(../images/shows_page_bg&pic.jpg) 50% 1000px fixed no-repeat;
height: 750px;
margin: 0 auto;
width: 100%;
position: relative;
box-shadow: 0 0 50px rgba(0,0,0,0.8);
padding: 100px 0;
min-height: 750px;
}
我希望你能帮我。
谢谢。您的图像尺寸是多少?你不工作是什么意思?它是否未显示或未更改?您可以转到new.rangafner.com并向下滚动到“显示”部分。似乎背景图像的起始位置不正确。这是一个有立方体的人的部分。在我的IE边缘正在工作。但是试着改变变量yPos=-Math.floor$window.scrollTop/$scroll.data'speed';为了消除这种震动效应,它没有震动。在它应该。。。