开发者

animating div background with use of jQuery

Ok, so I am trying to animated a DIV elements background-image with use of jQuery the background is a cloud which I would like to loop over and over in a slow like moving pattern. Any idea how I can do this?

I tried this code but no luck so not sure whats wrong.

$(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();
    });

    });

P.S. The background image it self is 1598 x 337px here is the way it looks if some one is interested: http://i54.tinypic.com/25zng2r.jpg


You can't by default, but you can use this plugin to achieve your desired result: http://www.protofunc.com/scripts/jquery/backgroundPosition/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜