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 7786075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:21:28+00:00 2026-06-01T20:21:28+00:00

In Chrome, the computed top property of an element may not be the same

  • 0

In Chrome, the computed “top” property of an element may not be the same as the “top” property as specified by setting its style. This is causing me problems with animation. It seems that jQuery animate starts by looking up the current computed style, but it updates by setting the specified style.

I’d like to know how best to work around this.

I have created a
simple example of the problem. In Firefox, type in a value in the box, e.g. -500, then click Go, and it will animate the “top” property of the ruler so that the needle points to 500. Type in 499 and click Go, and the ruler will hardly change. Now try the same thing in Chrome, with the zoom set to 83%. When you go from 500 to 499, there will be a big jerk in the animation. This is because jQuery is starting from the computed top which is -416px, then animating it to the specified top which is -499px.

Update. One person suggested using percent values rather than pixel values for the animation. That works — thanks! Is there a better way which will let me stick with my old pixel-based code?

  • 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-01T20:21:29+00:00Added an answer on June 1, 2026 at 8:21 pm

    If there’s a difference between style position and jQuery calculated position, then make jQuery calculate the start position before it begins, thus eliminating the difference. Assuming your style says the element is positioned at:

    .mydiv {top:120px;}
    

    But when you begin animating the div, Chrome thinks the element is at 111px instead…

    So, have jQuery get the top position for your starting point, and animate from there instead.

    var thePosition = $('div.mydiv').offset();
    var endLeft = thePosition.left - 500;
    var endTop = thePosition.top - 500;
    $(div.mydiv').animate({top : endTop, left : endLeft}, 'fast', function(){
        // do something on end
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Google chrome doesn't behave the same as other browsers when encountering this nugget: <?php
This div will have a computed height of 104.5px (in most recent Chrome, FF,
My Chrome Extension should modify a DOM element before the DOM is fully constructed,
In Chrome this is possible, but I don't find a way to do it
Google Chrome is acting buggy using border-radius, background color, and top and bottom borders.
I've got a simple button with a single css-style, like this: <button style=text-decoration:underline>That's a
I'm using a wonderful plugin computedstyle.js that gets the computed style of objects. It
I found this Page and after resizing windowwidth, it totally changed its css-values. I
So, check out this screenshot of a page I'm working on in Chrome Developer
i'm trying to get back a style property in all valid 'length' and 'percent'

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.