Re: [CSS21] top margin edge - hence static position - is not well-defined

On 01/04/2011 13:29, Peter Moulder wrote:
> On Sun, Mar 27, 2011 at 03:31:08PM +0200, Anton Prowse wrote:
>> Where should the absolutely positioned element be drawn in the
>> following test case, and why?
>>
>> <div style="border-bottom:1px solid; margin-bottom:20px"></div>
>> <div style="position:absolute; width:100px; height:100px;
>>    background: yellow; margin-top:10px"></div>
>> <div style="border-top:1px solid; margin-top:20px"></div>
>
> If we take the static position to be literally the position that it
> would be (as distinct from merely a guess) if it had position:static,
> then would it be fair to say that the answer is the same as the
> position of the yellow box in the above with s/absolute/static/ ?

> Thus, I can see the sense of Anton's proposal: the position of the
> content or border box is more meaningful for an abspos box than its
> margin box, so the intuition is that "same as where it would have been"
> should be based on content/border box rather than margin box.

> If we were to adopt the proposal, then could we achieve it by defining
> static position in terms of the top border edge instead of top margin
> edge?

Yes, that would possibly be less cumbersome than defining the top margin 
edge, and maybe it's anyway preferable just to make top and bottom 
margin edge position intentionally undefined when margin collapsing 
occurs.  (We're not suggesting redefining the 'top' property, of course; 
so the prose would have to factor the top margin width back in to the 
calculation when talking about using the top border edge as a handle on 
static position.)

>> Happily, there's a natural way of [defining top margin edge
>> position], since the general problem illustrated in the test case
>> only affects bottom margin, never top margin. Specifically, when a
>> box's top margin collapses with another margin thus contributing to
>> a final margin lump, the distance between the box's top border
>> position and the top of the margin lump is always at least as great
>> as the box's top margin width.
>
> Wouldn't a negative margin width falsify that?

Actually, yes.

> However, I don't really understand its relevance or how it affects
> the "meaningfulness" of the proposed definition

The "meaningfulness" (I probably should have said "intuitive") came from 
the idea that the top margin edge position in my proposed definition 
would necessarily lie inside the collapse margin lump.  (This is false 
for bottom margin edge position defined analogously, as demonstrated by 
my original "tricky" test case.)  However, that's not actually true in 
the case of negative margins, as you just pointed out.  No matter; that 
is the result of how the spec chooses to model the lump when negative 
margins are involved, which is something I don't necessarily agree with 
anyway (although I'm fine with the resulting border positions of the 
boxes and hence the actual visual rendering!).

So please ignore my attempt to justify my proposal – to define the top 
margin edge to be the distance above the top border edge given by the 
used value of 'margin-top' – as natural on the basis of the margin lump! 
  Instead, I agree with your description of it as being natural on the 
basis that the border box "same as where it would have been".

Cheers,
Anton Prowse
http://dev.moonhenge.net

Received on Friday, 1 April 2011 21:23:01 UTC