you may not like it but its correct 10.3.3 Block-level, non-replaced elements in normal flow
The following constraints must hold among the used values of the other properties: 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block If 'width' is not 'auto' and 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' (plus any of 'margin-left' or 'margin-right' that are not 'auto') is larger than the width of the containing block, then any 'auto' values for 'margin-left' or 'margin-right' are, for the following rules, treated as zero. If all of the above have a computed value other than 'auto', the values are said to be "over-constrained" and one of the used values will have to be different from its computed value. If the 'direction' property of the containing block has the value 'ltr', the specified value of 'margin-right' is ignored and the value is calculated so as to make the equality true. If the value of 'direction' is 'rtl', this happens to 'margin-left' instead. not consistent with other things, confusing whatever but it seems to be according to the spec. So spec is the one to blame here not the browsers, and IE is not following the spec. On May 15, 2011, at 3:07 PM, Joel Dart wrote: > <According to the CSS 2.1 spec, a computed value of 'auto' for 'margin-left' > or 'margin-right' becomes a used value of '0': > <http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins> > > Yes, for inline-replaced elements that is the case, but my example is > covering a different case. I was using a div with display: block which falls > under the block-level, non-replaced elements section (10.3.3). The > description at the end of that sections states if they're auto their used > values are equal, horizontally centering the element (as you can see is > properly done visually). > > Visually, it is doing the right thing but not reporting that value back > through the call to getComputedStyle(element, > null).getPropertyValue("margin-left"). > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
