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

Le Lun 11 octobre 2010 8:30, Boris Zbarsky a écrit :
> 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

For the testcases, I always assume a minimum of 640px of viewport width.

> and if the body padding is 8px
> in the UA.

Body padding must be 8px? Are you sure? Both testcases had body {margin:
8px;} which is the default in browsers.

> 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.

Ok, great! This is what I was missing.

>
> 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.


The CSS 2.1 test suite testcases require a viewport width minimum of 640px.

Boris, I do not understand where does that 8px body padding comes from..

>> 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....
>
> -Boris

regards, Gérard
-- 
CSS 2.1 Test suite RC2 (October 1st 2010)
http://test.csswg.org/suites/css2.1/20101001/html4/toc.html

Contributions to CSS 2.1 test suite
http://www.gtalbot.org/BrowserBugsSection/css21testsuite/

Web authors' contributions to CSS 2.1 test suite
http://www.gtalbot.org/BrowserBugsSection/css21testsuite/web-authors-contributions-css21-testsuite.html

Received on Monday, 11 October 2010 21:40:15 UTC