Skip to main content

Bug Tracker

Side navigation

#11584 closed bug (invalid)

Opened April 12, 2012 11:25AM UTC

Closed April 12, 2012 11:30AM UTC

Last modified April 12, 2012 04:21PM UTC

outerWidth(true) inconsistent on float: none; margin: auto;

Reported by: aquiva@gmail.com Owned by:
Priority: low Milestone: None
Component: dimensions Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

http://jsfiddle.net/4DFSh/1/

outerWidth(true) returns an inconsistent value between browsers when a DIV has no float and auto margins.

Details in the JSFiddle, load in all browsers available to see inconsistency.

Attachments (0)
Change History (3)

Changed April 12, 2012 11:30AM UTC by sindresorhus comment:1

component: unfileddimensions
priority: undecidedlow
resolution: → invalid
status: newclosed

.outerWidth(true) will return the width including margins. Since you've set the margin to auto, the margin will fill the width of the window.

Changed April 12, 2012 02:09PM UTC by anonymous comment:2

So cross browser consistency is not desired in jQuery? That seems bizarre.

Changed April 12, 2012 04:21PM UTC by mikesherov comment:3

Of course it's desired. The problem here is that browsers differ here in a way that makes it impossible for us to fix. I've already petitioned the browser vendors to fix this.

What's funny about this fiddle is that it says the "correct" value is 200px. However, when margin is "auto", the value is greater than zero. That's what centers the box. That's why you said auto. The correct value is actually what Chrome reports, 836.

For more information, see here:

https://bugzilla.mozilla.org/show_bug.cgi?id=381328

https://bugs.webkit.org/show_bug.cgi?id=73334