collapsing margin-bottom in Internet Explorer

When I view the HTML/CSS below in Internet Explorer 6 for Windows, the menu in div "one" collapses the bottom margin of all but the last 2 buttons as my mouse rolls down over the buttons, then restores the bottom margins when I roll my mouse upward. Using a top margin in div "two" fixes the problem. I've never seen different behaviour from rolling over an object up vs. down, and the page works fine in other browsers I tried. Can anyone explain this behavior?

I'll post the code for a while here: http://perfectweb.com/experts/ie6_margin_collapse.html

-------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <style type="text/css">

body {
      position:                  relative;
      font:                        xx-small verdana, arial, sans-serif;
      background-color:      #fff;
      margin:                        0;
      padding:                  0;
}
#one .button {
      margin-bottom:            10px;
}
#two .button {
      margin-top:                  10px;
}
a.button {
      display:                  block;
      width:                        20%;
      text-decoration:       underline;
      font-size:                  x-small;
      font-weight:            bold;
}
a.button:link, a.button:visited {
      background-color:      #ccc;
      color:                         blue;
}
a.button:hover, a.button:active {
      background-color:      #333;      
      color:                        red;
}



      </style>
</head>
<body>
the following menu uses margin-bottom:
<div id="one">
<a href="#" class="button">menu one</a>
<a href="#" class="button">menu two</a>
<a href="#" class="button">menu three</a>
<a href="#" class="button">menu four</a>
<a href="#" class="button">menu five</a>
</div>
<br /><br />
the following menu uses margin-top:
<div id="two">
<a href="#" class="button">menu one</a>
<a href="#" class="button">menu two</a>
<a href="#" class="button">menu three</a>
<a href="#" class="button">menu four</a>
<a href="#" class="button">menu five</a>
</div>

</body>
</html>
LVL 6
merwetta1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VirusMinusCommented:
having a look.. IE7 renders it fine.

I think it could be a IE6 reflow margin bug;
http://www.positioniseverything.net/explorer/percentages.html
merwetta1Author Commented:
The comment from VirusMinus was not a solution. I never figured out a solution. You may delete the question.
VirusMinusCommented:
If it wasn't then you should've let us know it wasn't and we would try and help figure out more. I'm happy to continue looking into this further and requesting other experts to look at it too.
merwetta1Author Commented:
you are absolutely right, Virus Minus. I should have posted that your solution didn't work. so in the spirit of better late than never...

The article you mention discusses an IE6 bug with computing percentages and the issues related to using percentages for width and height. The problem demonstrated in my example is not related. The only percentage used in my sample is the a.button width, and changing that to a pixel value does not effect the collapsing margins.

It's really quite a weird and interesting IE6 bug if you or anyone else care to take a look at it in IE6.

GrandSchtroumpfCommented:
That's a horrible IE6 bug.
It's the background-color change that causes the bug.

It's documented here:
http://www.quirksmode.org/bugreports/archives/2004/12/losing_bottom_margin_of_previous_element_when_hove.html

The workaround is to use margin-top instead of margin-bottom, as you found out.
Floating your <a> also seems to fix the problem, but margins on floated elements never collapse.
In both cases, that prevents you from using the normal behaviour of collapsing vertical-margins.

IE6 is a horrible browser and IE7 is not that much better.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.