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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:08:23+00:00 2026-05-15T07:08:23+00:00

So, this is a problem that’s been asked before, but I’m hoping we can

  • 0

So, this is a problem that’s been asked before, but I’m hoping we can lay it to rest: I’m using jQuery 1.4. If I define the style

#obj { margin: 0 auto; }

and then do

$('#obj').css('marginLeft');

the result is the computed value in pixels. Is there any way to tell whether those pixels come from the auto calculation or not, without parsing document.styleSheets?

  • 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-05-15T07:08:23+00:00Added an answer on May 15, 2026 at 7:08 am

    This solution would also be triggered if the margins were set to percentages, but it might be good enough for your purposes. Basically, you record which margins change on resize. So you’d record the margins before resize to an array:

    var aMargins = [];
    $('.yourObjs').each(function(i,obj){
      var objML = $(obj).css('marginLeft');
      aMargins.push(objML);
    });
    

    Then resize the window, see which margins changed (these will be either ‘auto’ or %), do what you need to do to them and return he window to original size:

    var wW = $(window).width();
    var wH = $(window).height();  
    window.resizeTo(wW - 5, wH);
    $('.yourObjs').each(function(i,obj){
      if ($(obj).css('marginLeft') != aMargins[i]) {
        // your centering code here
      }
    }
    window.resizeTo(wW,wH);
    

    If your centering code just adjusts the left margin then this should work fine for % based margins too. I can’t test this code or provide an example because I’m on the road and writing from my phone, but hopefully this works or helps you come up with something that will.

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

Sidebar

Related Questions

There was this problem that has been asked about implementing a load byte into
This has been a problem that I haven't been able to figure out for
This is a really weird problem that I have been having. When I download
So I'm been pounding on this problem all day. I've got a LinqDataSource that
Has anyone else run into this problem before? I've got a method that calls
Never used a cache like this before. The problem is that I want to
This is an interesting problem that I’ve not been able to solve yet. I
Ok I have this problem that I've never had before, it's really bugging me.
I got this problem that I can't just solve algorithmically. Let's say i have
This is a problem that has been eating at me for a while, and

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.