W3C home > Mailing lists > Public > www-style@w3.org > October 2010

Re: [CSS 2.1][Section 10.3.7] Calculating width and margin-left for abs. pos. with max-width constraint

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Mon, 11 Oct 2010 11:30:17 -0400
Message-ID: <4CB32D89.6050802@mit.edu>
To: www-style@gtalbot.org
CC: www-style list <www-style@w3.org>
On 10/11/10 12:33 AM, "Gérard Talbot" wrote:
> http://www.gtalbot.org/BrowserBugsSection/css21testsuite/absolute-non-replaced-width-025.htm
> http://www.gtalbot.org/BrowserBugsSection/css21testsuite/absolute-non-replaced-width-026.htm
> 1- Are those 2 testcases correct?

Yes, if the window is sufficiently wide and if the body padding is 8px 
in the UA.  For the first one, section 10.3.7 means that width is 
computed, and if it computes to more than 100px then the rules are 
applied _again_ assuming a computed width of 100px.  Then all three of 
width/left/right are non-auto, both margins are auto, so the margins get 
equal values.

For the second one, the same reasoning applies, but now only one margin 
is auto, so it's solved for directly.

I'd suggest making the body position:relative and setting left/right to 
0 throughout so as to avoid the "if the window is sufficiently wide and 
if the body padding is 8px in the UA" assumptions.

> 3- One issue that puzzles me is that the spec [1] says to
> {
> set 'auto' values for 'margin-left' and 'margin-right' to 0, and [if]
> (...) 5. 'width' is 'auto', 'left' and 'right' are not 'auto', then solve
> for 'width'."
> }
> a) is setting the 'margin-left: auto' to 0 and 'margin-right: auto' to 0
> permanent or done only for the purposes of calculating width?

What's being set to 0 is the used value of margin-left and margin-right. 
  Then the used value of width is computed.

If the result gives width > max-width, all values are reset back to 
their computed values, computed width is set to 100px, and the 
computation in 10.3.7 is redone.  I agree that the spec could be clearer 
on this....

Received on Monday, 11 October 2010 15:30:53 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:39 UTC