jQuery在块中动画背景位置? [英] jQuery animate background position in chunks?
问题描述
我想使用jQuery使我的跨度的背景位置每秒下降10像素。这是一个很好的方法吗?
I'm trying to use jQuery to make a background position of my span go down 10 pixels every second. What is a good way to do this?
我一直在玩jQuery animate,延迟,CSS和一些 setTimeout
函数,但我不能得到任何工作。
I've been playing with jQuery animate, delay, CSS, and some setTimeout
functions but I can't get anything to work. Suggestions greatly appriciated!
我试图让我的y位置从0到100以10像素为增量,然后停止动画。
I'm trying to make my y-position go from 0 to 100 in increments of 10 pixels, and then stop the animation.
推荐答案
jQuery不能正确地设置背景位置的动画,因为需要动画两个值而不是一个。此处的解释和解决方案:
jQuery can't animate background position properly because of the need to animate two values instead of just one. Explanation and solution here:
http://snook.ca/archives/javascript/jquery-bg-image-animations/
这篇关于jQuery在块中动画背景位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!