/    Sign up×
Community /Pin to ProfileBookmark

margin-top Firefox BUG

I have a problem with nested divs and using margin-top. I am hoping somebody could help me find a solution. I made a really simple example of what I am trying to do. Here is the link: [url]http://www.barretmonchka.com/connections/marginprob.html[/url]

In IE, the top margin is properly applied to the red div to distance it from the top of the blue div. However, in Firefox, the top margin of the red div is applied to the blue div (it’s parent element). Does anybody know what I could do? Your help would be so much appreciated.

Different doctypes did not help the matter.

Here is the code:

<html>
<head>
<title></title>
<meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1″ />
<style type=”text/css”>

table#main{
width: 100%;
height: 100%;
}

table#main td{
width: 100%;
height: 100%;
vertical-align: middle;
text-align: center;
}

div#blue{
margin-right: auto;
margin-left: auto;
width: 780px;
background-color: blue;
text-align: left;
height: auto;
}

div#red{
width: 611px;
height: 484px;
background-color: red;
margin-top: 55px;
margin-left: 130px;
}

</style>

</head>

<body>

<table id=”main”>
<tr>
<td>

<div id=”blue”>
<div id=”red”></div>
</div>

</td>
</tr>

</table>

</body>
</html>

thanks so much,
Barret

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyJun 23.2006 — Trydiv#blue{
position:absolute;
margin-right: auto;
margin-left: auto;
width: 780px;
background-color: blue;
text-align: left;
height: auto;
}
Copy linkTweet thisAlerts:
@Orc_ScorcherJun 23.2006 — Add the following to the blue div's CSS rules:border-top: 1px solid transparent;
Copy linkTweet thisAlerts:
@drhowarddrfineJun 24.2006 — First, you will never get IE to display the same as modern browsers like Firefox without a proper doctype. See my link below. Use html4 strict.

Second, IE is displaying your code incorrectly as it is in quirks mode.

Third, without looking into it further, you are probably experiencing margin collapse bug in IE.

Your problem is IE not Firefox.
×

Success!

Help @bmonchka spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...