Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7824867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:44:31+00:00 2026-06-02T08:44:31+00:00

My situation started like this: I wanted to animate the background image of a

  • 0

My situation started like this: I wanted to animate the background image of a div, but it seems, with jquery I can’t retrieve the individual positions of the background images(background-position). So I thought why not create a object and animate it’s values then just put this values in the css, but i can’t figure out how to quite do it yet. Here’s what I tried.

var obj={t:0};
                $("#wrapper").animate({
                    obj:100 //I tried obj.t & t as well
                },1000,'linear',function(){},function(){
                    $("#wrapper").css({
                            'background-position':obj.t+"% 0%"
                        });
                });

Also another question I need to ask is, if the picture is really big, I mean about 4000x4000px, would it be better to set it as a background image and change the background position, or move around the div itself?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:44:32+00:00Added an answer on June 2, 2026 at 8:44 am

    You need to use the step function of the animate method, and more importantly you need to animate the actual object.. not the #wrapper element

    var obj = {
        t: 0
    };
    
    $(obj).animate({ // call animate on the object
        t: 100 // specify the t property of the object to be animated
    }, {
        duration: 1000,
        easing: 'linear',
        step: function(now) { // called for each animation step (now refers to the value changed)
            $("#wrapper").css({
                'background-position': now + "% 0%"
            });
        }
    });
    

    Demo at http://jsfiddle.net/gaby/yPq8s/1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a simple website . My situation is like this. After registering
My situation is like this: Everytime before uploading war file to web-app folder, I
I searched for this but I can't seem to find a similar case that
I have a particular situation: a service started by a broadcast receiver starts an
Situation: I often run into this problematic and never know how to solve it.
Situation: I have some persons with certain skills and they can/might belong to more
Firslty, I'm aware of some similar questions along the lines of this one, but
Here again! The situation is this, I have: Activity A that implements a viewPager
I just started using GIT yesterday and i was trying to do something but
I'm new to Drupal and I'd like to get this quickly implemented, or at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.