merwetta1
asked on
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>
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>
ASKER
The comment from VirusMinus was not a solution. I never figured out a solution. You may delete the question.
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.
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think it could be a IE6 reflow margin bug;
http://www.positioniseverything.net/explorer/percentages.html