Previous Message
Next Message

Using clearing elements to prevent margin collapse

Sent by Andy Budd on 12 July 2004 10:10


Hi Michael,

Whenever 2 margins touch they collapse. If you're div doesn't contain 
any real content then the top margin will collapse into the bottom one. 
This is why you're top set of examples don't work but your bottom set 
does.

see

http://www.andybudd.com/archives/2003/11/no_margin_for_error/index.php

for a better explanation.


Michael Ryznar wrote:

> In terms of using a clearing element to prevent margin collapse 
> surprisingly these common clearing techniques do not work:
>
> <div class="clearer">&nbsp;</div>
> <div class="clearer"><!-- --></div>
> <div class="clearer"></div>
> <br class="clearer" />
>
> However these clearing elements do work:
> <div class="clearer">b</div>
> <div class="clearer">d</div>
> <div class="clearer">g</div>
>
> Very strange. Obviously there needs to be something substantial in the 
> clearing element. But why do only certain characters work?

Andy Budd

http://www.message.uk.com/

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread:

Possibly related: