Re: Float margin relativity (Was Re: Underhang protection)

On Wed, 28 Feb 2007, Daniel Beardsmore wrote:
> 
>   <div style="display: float; width: 10em; height: 6em; border: 2px solid
> black;
>   margin: 0.5em">Float</div>
> 
>   <blockquote>This is a quotation</blockquote>
> 
>   <p>Lorem ipsum dolor</p>
> 
> This will produce:
> 
> +------------------+ This is a quotation
> |Float             |
> |                  | Lorem ipsum dolor
> |                  |
> |                  |
> +------------------+
> 
> The blockquote normally has a left margin relative to its parent 
> container, but when it sits to the right of a float, it doesn't. I would 
> guess that there's a nasty hack somewhere for this, too, but IMO a left 
> margin on an element to the right of a float, should be obeyed.
> 
> Both padding-left and margin-left are relative to the container element 
> (here, assumably body) and are not influenced by floats. Thus, if you 
> place floats within text, any items such as blockquote and bulleted 
> lists will (with conventional default styling) get their left margins 
> "removed".

This is a known problem and CSS3 has had the proposed float-displace and 
intend-edge-reset properties to handle it since 2002 or so:

   http://www.w3.org/TR/css3-box/#the-float-displace

HTH,
-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Wednesday, 28 February 2007 21:58:40 UTC