Re: Float clearing a float when inside a self-collapsing block with margin-top

On Mon, 26 Nov 2012 20:12:46 +0100, Robert Hogan <robhogan@gmail.com>  
wrote:

> It seems like the correct position of the black float in this snippet
> is directly below the blue float:
>
> <p>The blue box should be stacked on top the black box.</p>
> <div style="height: 20px; width:20px; float:left; background:  
> blue;"></div>
> <div style="margin-top:10px; clear:both;">
>     <div style="height: 20px; width:20px; float:left; background:  
> black;"></div>
> </div>

Yes.

> However if we follow http://www.w3.org/TR/CSS21/visuren.html#clearance
> the outer top of the black float's parent (which is a self-collapsing
> block) should be halfway down the blue float, because the remaining
> 10px of the blue float's height is accounted for by the
> self-collapsing block's 10px of top-margin.

Yes.

> So with this in mind, it's not clear to me what, in the spec, forces
> the black float to only go as far as the top border edge of its parent
> (so that it clears the blue float completely) rather than the outer
> top of its parent as it would normally do (where it will avoid the
> blue float rather than clear it).

I'm not sure why you say that's what it would normally do. The top of the  
black float may not go higher up than the content edge of its parent, per  
<http://www.w3.org/TR/CSS21/visuren.html#float-rules> and  
<http://www.w3.org/TR/CSS21/visudet.html#containing-block-details>.

-- 
Øyvind Stenhaug
Opera Software ASA

Received on Tuesday, 27 November 2012 09:29:21 UTC