User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 402,000 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,438 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 1557 | Replies: 2
Reply
Join Date: Apr 2007
Posts: 1
Reputation: drarock is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
drarock drarock is offline Offline
Newbie Poster

Firefox2.0 and margin-top

  #1  
Apr 10th, 2007
Hello I have a div inside other div with a margin-top, it looks good in Ie7 but i have an issue in firefox, it doesn't work the margin-top


/*CSS*/
#main{background-color:#003399; height:50px; margin-top:10px; width:300px;}
 
#child{background-color:#993300; height:50px; margin-top:10px; margin-bottom:10px; margin-right:10px;}
 
/*HTML*/
 
<div id="main">
<div id="child">test</div>
</div>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 943
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 47
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: Firefox2.0 and margin-top

  #2  
Apr 11th, 2007
Try using a padding-top:10px for the main div instead of a margin-top:10px for the child div, and a padding-top of 10px on the body instead of a margin-top on the main div.

I can't tell you why it doesn't work; but it doesn't seem to work on Opera either o_O
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Jan 2007
Posts: 2,537
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 109
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: Firefox2.0 and margin-top

  #3  
Apr 16th, 2007
You didn't leave enough room for the child to fit inside the main.

Unless the margins, borders, and paddings are all set to 0, space is needed for a complete set of these inside the main, but surrounding the child.

When stuff doesn't fit, the browser looks to see where it can steal some pixels to force-fit it. Sledgehammer rendering at work!

Your child object is 70 pixels tall with the margins, and you are trying to cram it inside the main object, which is 50 pixels tall.

It's kind of like all of the department-store Santa Clauses in the world trying to go down the same chimney all at once.
Last edited by MidiMagic : Apr 16th, 2007 at 11:58 pm.
Daylight-saving time uses more gasoline
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb HTML and CSS Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the HTML and CSS Forum

All times are GMT -4. The time now is 9:03 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC