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

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

From: Anton Prowse <prowse@moonhenge.net>
Date: Tue, 27 Apr 2010 01:12:59 +0200
Message-ID: <4BD61DFB.4030604@moonhenge.net>
To: "www-style@w3.org" <www-style@w3.org>
CC: Bruno Fassino <fassino@gmail.com>
Bruno Fassino wrote:
> 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.
> 

I think you're completely right :-)  I had of course overlooked this.

It's a little naughty of the spec to lead one into thinking that an
illegal used value for 'width' were being prescribed in 10.3.7 (and, of
course, in 10.3.3, which also didn't occur to me to look at), only to
then pull the rabbit out of the hat in 10.4 by qualifying it as
"tentative";  I would prefer a note in the introduction to 10.3 (and by
analogy, 10.6), such as the following:

   | The used value for 'width' calculated according to the rules in this
   | section is tentative, being subject to the rules in 10.4.

...although this might just be me being sheepish, having been tripped up ;-)


One other editorial issue:

Shouldn't the word "computed" be added where indicated in the following?

In 10.4:
   | 2. If the tentative used width is greater than 'max-width', the
   |    rules above are applied again, but this time using the computed
   |    value of 'max-width' as the computed value for 'width'.
   | 3. If the resulting width is smaller than 'min-width', the rules
   |    above are applied again, but this time using the _computed_ value
   |    of 'min-width' as the computed value for 'width'.

In 10.7:
   | 2. If this tentative height is greater than 'max-height', the rules
   |    above are applied again, but this time using the _computed_ value
   |    of 'max-height' as the computed value for 'height'.
   | 3. If the resulting height is smaller than 'min-height', the rules
   |    above are applied again, but this time using the _computed_ value
   |    of 'min-height' as the computed value for 'height'.


Cheers,
Anton Prowse
http://dev.moonhenge.net
Received on Monday, 26 April 2010 23:13:58 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:26 GMT