Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11584 closed bug (invalid)

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

Reported by: aquiva@… Owned by:
Priority: low Milestone: None
Component: dimensions Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:



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.

Change History (3)

comment:1 Changed 11 years ago by sindresorhus

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.

comment:2 Changed 11 years ago by anonymous

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

comment:3 Changed 11 years ago by mikesherov

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

Note: See TracTickets for help on using tickets.