Modify ↓
Ticket #1160 (closed bug: wontfix)
Dimensions: <body> with margin auto results in bogus values from offset() on IE
| Reported by: | mikeker | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.1.3 |
| Component: | plugin | Version: | 1.1.2 |
| Keywords: | dimensions | Cc: | |
| Blocking: | Blocked by: |
Description (last modified by brandon) (diff)
Using the Dimensions plugin (v 1.0a) and jQuery (v1.1.2). On IE (6 or 7), offset() doesn't take into account the margin on the <body> tag when margin: auto is specified. Works as expected on FF2. Workaround is to insert wrapper div just inside the <body> tags and put your <body> styling there.
Example:
<script type='text/javascript'>
$( document ).ready( function () {
alert( $( '#test' ).offset().left );
});
</script>
...
<body style='width: 600px; margin: auto;'>
<p>
Lorem ipsum dolor sit amet, <a id='test' href='#'>massa</a> elit facilisis, enim sociis lacinia in dui fusce quam etc.etc.etc.
</p>
</body>
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Margins, borders and padding must be specified in pixel values for the calculations to be correct in IE. Unfortunately fixing IE in this manner would bring offset to a screeching halt in performance.