SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery and sprites

    I have a sprite containing images in a line which are identical except each image is rotated 40degrees more than the previous image. Is it possible to use jQuery with sprites so that the background position of a div changes after a delay.
    I've been messing about with some code but with no success.

  2. #2
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    You'd want to do something like this:
    Code:
    var timeInMS = 100;
    var pos = 0;
    
    setInterval(function() {
      $('.moveMe').css({'background-position: ' + pos + 'px 0'});
      pos += 40;
    }, timeInMS);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •