Quote:
Originally Posted by Gesp Thanks anyway, as long as this is a test I`ll wait with this solution and then try to find an other easier way. |
Once again, a picture speaks 1,000 words.
I believe I now know what you were trying to describe in your post above. The behavior you're seeing is called
"Collapsing Margins". In your case, the way to deal with that is to add 1px padding to the top of the "master_enter" DIV and the DIVs should align properly.
Here is your original HTML from above:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {padding:0 auto; margin:0 auto; background:#FFF repeat-x top}
div#master_enter{width:1024px; height:768px; background:#F00; margin:0 auto}
div#master{ width:1024px; height:auto}
div#enterButton_selection{width:62px; height:17px; margin:478px 0px 0px 468px; padding:1px 0px 0px 0px; text-align:center; border:solid 1px #FFF; background:#87d9ff; filter:alpha(opacity=20); opacity:0.2; font-family:"Berlin Sans FB", Calibri, Arial; font-size:12px; color:#FFF;}
div#enterButton_selection:hover{width:62px; height:17px; margin:478px 0px 0px 468px; padding:1px 0px 0px 0px; text-align:center; border:solid 1px #FFF; background:#87d9ff; filter:alpha(opacity=60); opacity:0.6; font-family:"Berlin Sans FB", Calibri, Arial; font-size:12px; color:#FFF; text-decoration:underline}
div#footer{ width:100%; height:200px}
</style>
</head>
<body>
<div id="master_enter">
<div id="enterButton_selection">Enter</div>
</div>
</body>
</html>
The reason I didn't see the issue previously is I accidentally "fixed" the collapsing margin issue before I viewed the page.
I was able to fix the collapsing margins by doing one of two things, per the CSS2.1 spec:
1) Add a 1px border to the "master_enter" DIV
Code:
div#master_enter{width:1024px; height:768px; background:#F00; border: 1px solid #fff; margin:0 auto}
2) Add a 1px padding to the "master_enter" DIV
Code:
div#master_enter{width:1024px; height:768px; background:#F00; padding: 1px 0; margin:0 auto}
Doing either of those things solves your problem. All of the "work" you did above isn't necessary.
In addition to that, I simplified the CSS a bit more to produce this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body {padding:0 auto; margin:0 auto; background:#FFF repeat-x top}
div#master_enter{width:1024px; height:768px; background:#F00; padding: 1px 0; margin:0 auto}
div#master{ width:1024px; height:auto}
div#enterButton_selection{width:62px; height:17px; margin:478px auto 0px auto; text-align:center; border:solid 1px #FFF; background:#87d9ff; filter:alpha(opacity=20); opacity:0.2; font-family:"Berlin Sans FB", Calibri, Arial; font-size:12px; color:#FFF;}
div#enterButton_selection:hover{filter:alpha(opacity=60); opacity:0.6; text-decoration:underline;}
div#footer{ width:100%; height:200px}
</style>
</head>
<body>
<div id="master_enter">
<div id="enterButton_selection">Enter</div>
</div>
</body>
</html>
I have also been bit by the
collapsing margin behavior which is why I'm familiar with it. You can also check out
this thread.
Peace...