jQuery图像向上滑动而不是向右滑动
基本上,我的代码是在我希望图像向右滑动时使其向上滑动。怎么了 HTMLjQuery图像向上滑动而不是向右滑动,jquery,html,Jquery,Html,基本上,我的代码是在我希望图像向右滑动时使其向上滑动。怎么了 HTML <div id="wrapper"> <div id="header"> </div> </div> 下面是代码:您需要增加值 function scrollBg(){ //Go to next pixel row. current += step; //increment instead of decrement //If at
<div id="wrapper">
<div id="header">
</div>
</div>
下面是代码:您需要增加值
function scrollBg(){
//Go to next pixel row.
current += step; //increment instead of decrement
//If at the end of the image, then go to the top.
if (current == restartPosition){
current = 0;
}
//Set the CSS of the header.
$('#header').css("background-position",current +"px 0"); // parameters are right top not top right
}
演示:更新:我找到了答案
$('#header').css("background-position","0 "+current+"px");
我将0更改为1,它将其修复。这纯粹是运气使然,但为什么要这样做呢
$('#header').css("background-position","0 "+current+"px");