好的,所以我正在尝试使用 jQuery 为 DIV 元素背景图像制作动画,背景是一朵云,我想以缓慢的移动模式一遍又一遍地循环。知道我该怎么做吗?
我试过这段代码,但运气不好,所以不确定哪里出了问题。
$(document).ready(function() {
$(function() {
$.fn.extend({
animateHeader: function(){
$(this).find('#header').css('background-position', '0px 0px');
$(this).find('#header').animate({
backgroundPosition: '-20px 0px'
}, 100, 'linear', function() {
animateHeader(self);
});
}
});
});
$(document).ready(function() {
$(this).animateHeader();
});
});
附言它自己的背景图像是 1598 x 337px 如果有人感兴趣的话,这里是它的样子:http://i54.tinypic.com/25zng2r.jpg
最佳答案
默认情况下你不能,但你可以使用这个插件来实现你想要的结果: http://www.protofunc.com/scripts/jquery/backgroundPosition/
关于jquery - 使用 jQuery 动画 div 背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6905624/