Re: [CSS21] 10.3.7 & 10.6.4 - Absolutely positioned elements and incompatible offsets

On Mon, Apr 26, 2010 at 8:34 AM, Anton Prowse <prowse@moonhenge.net> wrote:
> CSS2.1 is careful to ensure that all possible cases are covered when
> calculating the widths, heights and margins of absolutely positioned
> elements for all possible values of 'left', 'right', 'top', 'bottom',
> 'margin', 'width' and 'height'.  However, the description of one of
> these cases seems to be flawed.
>
> <div style="position:relative; width:100px">
>        <div style="position:absolute; left:60px; right:60px;">
> </div>
>
> (See test cases [1,2].)
>
> As described in 10.3.7 Absolutely positioned, non-replaced elements,[3]
> the constraint that determines the used values is:
>
> 'left' + 'margin-left' + 'border-left-width' + 'padding-left' + 'width'
> + 'padding-right' + 'border-right-width' + 'margin-right' + 'right' =
> width of containing block
>
> According to the spec, in the situation given by the test case we must
> set 'auto' values for 'margin-left' and 'margin-right' to 0 and, since
> Rule 5 applies, we solve for 'width'.
>
> Alas, this gives rise to an illegal 'width' used value of -20px.


I may be completely wrong, but isn't this case taken into account by min-width ?

The rules about min-width at 10.4 are always applied, min-width has an
initial value of 0, so any negative width resulting from a previous
rule is regarded as a "tentative used width" and being smaller than
min-width:
<quote>the rules above are applied again, but this time using the
value of 'min-width' as the computed value for 'width'</quote>
This time at 10.3.7 the part "none of the three (left, width right) is
auto" will apply.

Bruno


> [1]
> http://dev.moonhenge.net/css21/test-cases/positioning/incompatible-horizontal-offsets.html
> [2]
> http://dev.moonhenge.net/css21/test-cases/positioning/incompatible-vertical-offsets.html
> [3] http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width
> [4] http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height
>
> Cheers,
> Anton Prowse
> http://dev.moonhenge.net


-- 
Bruno Fassino http://www.brunildo.org/test

Received on Monday, 26 April 2010 09:30:14 UTC