jQuery animate background position in chunks?

2020-04-11 04:12发布

问题:

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?

I've been playing with jQuery animate, delay, CSS, and some setTimeout functions but I can't get anything to work. Suggestions greatly appriciated!

I'm trying to make my y-position go from 0 to 100 in increments of 10 pixels, and then stop the animation.

回答1:

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/