Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

margins, divs and Firefox

Status
Not open for further replies.

Halcrow

Programmer
Aug 24, 2004
76
0
0
GB
I have a div in my page which takes up the full length of the screen. Under it I have another, similar div. I want a gap between them, so I set margin-bottom: 50px for the first one.

In Firefox, this has no effect, and places the divs right next to each other. But, if I give the first one a border (border: 1px solid black) the gap suddenly appears! The gap isn't there is no border is set for the first one.

What is going on here?

Thanks
Calum
 
...isn't there if no border....

is it possible to edit your posts once they are up?
 
Are you using a complete doc-type? You might have an error in your CSS:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]

<html>
<head>
<title>new document</title>

<style type="text/css">
#the_top {
    width: 100%;
	height: 300px;
	background-color: gray;
	margin-bottom: 50px;
}
#the_bottom {
    width: 95%;
	height: 200px;
	background-color: yellow;
}
</style>

</head>

<body>
<div id="the_top"></div>
<div id="the_bottom"></div>
</body>

</html>

No, there's no way to edit your post :(

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
does it have to be strict dtd?
my doc type is this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
will that affect my CSS?

----------------------------------------
Sometimes, when my code just won't behave, I take it outside and make it listen to britney spears music, and when it comes back it's really well behaved. I wonder if it's suffering from post tramatic stress syndrome now..
 
Nope, just a doctype.

My solution above worked with your doctype.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Something funny is happening on my page, but I think it must have to with another aspect of my design because when I prepared a basic example of my problem everything worked fine.

Sorry about that.

Calum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top