473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CSS margin problems in Firefox vs IE

JnrJnr
88
Hi people, I have a div, inside the div is a heading and a table. I want the table to be say 50px from the bottom of the heading. So I give the table a margin-top50px. In FF it calculates the table's margin against the heading and in IE it calculates the margin against the top of the div, see attached image.
Could you please explain or guide me to what the problem is with the margins in Firefox and IE.
I've read the article on collapsing margins here http://complexspiral.com/publication...psing-margins/ but its still not working for me.
Attached Images
File Type: jpg Untitled.jpg (19.5 KB, 647 views)
Dec 30 '11 #1
11 6032
In the markup, are you setting the relativity explicitly? Even though there are standards, I've run across issues with browsers not having the same "defaults" when it comes to CSS. If setting the relativity doesn't fix the problem, let us know and we'll figure this out together :)

One more thing, what versions of said browsers are you using? This can help out quite a bit when troubleshooting cross-browser issues.

- - - - - -
- EDIT -
- - - - - -
After re-reading your post again, I realized what you were actually asking. Silly me, I shouldn't be up this late. ;)

Although what I posted above does have merit in the answer, it doesn't explain is clearly. As I mentioned, every browser has it's own way of doing things and this includes defaults for CSS. Just about anyone who has done any webdesign and tried to make it cross-browser compatible will tell you that IE is a big culprit for breaking CSS.

As far as the issue goes that you're having, you could always add a browser specific markup. However, some believe this is cheating. There is supposed to always be a way around it (keyword: supposed) using pure CSS.
Dec 30 '11 #2
JnrJnr
88
Hi, I do not understand what you mean with the "relativity". Could you explain that to me. I'm still learning.
Dec 30 '11 #3
Sorry about that, I shouldn't be assuming. :) I used the term "relativity" as in the positioning of the div. position: relative|absolute|etc It's just a positioning CSS rule for layouts/divs/etc.

For more info: W3C
Dec 30 '11 #4
JnrJnr
88
Ok, well I dont know if this is good practise but it seems like absolute positioning works. When I apply absolute position to the table then the table's margin top is set relative to the heading and not the div.
Dec 30 '11 #5
drhowarddrfine
7,435 Expert 4TB
When looking at how browsers work, Firefox will show what you wrote. IE will make things up as it goes along. Never, ever trust IE to do anything right.

Without a link, or the complete markup, anything we say is just a wild guess.
Dec 30 '11 #6
JnrJnr
88
I've noticed. Sad to be honest.
Ok the markup is pretty straight forward...

HTML
Expand|Select|Wrap|Line Numbers
  1. <div id="container">
  2. <h2>Hello Heading</h2>
  3. <table width="200" style="margin:50px 50px">
  4. <tr><td></td></tr>
  5. </table>
  6. </div>
CSS
Expand|Select|Wrap|Line Numbers
  1. #container
  2. {
  3.   width:300px;
  4.   height:500px;
  5.   float:left;
  6.   position:absolute;
  7.   margin-left:410px;
  8.   margin-top:160px;
  9. }
Dec 30 '11 #7
drhowarddrfine
7,435 Expert 4TB
I don't see any difference. Are you using IE9? Are you using a doctype?
Dec 30 '11 #8
JnrJnr
88
That is strange. I am using IE 9. My document type is
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
I coppied the code I posted and ran the page in both IE and FF and this is what it looks like - see attached image.
When I add position absolute to the table then the table's margins are the same as in FF making them look the same in both browsers.
Attached Images
File Type: png Capture.PNG (50.5 KB, 338 views)
Dec 31 '11 #9
dear JnrJnr

use the following codes
HTML
Expand|Select|Wrap|Line Numbers
  1. <div id="container">
  2. <h2>Hello Heading</h2>
  3. <table width="200" style="margin:50px 50px">
  4. <tr><td>this is the table</td></tr>
  5. </table>
  6. </div>
  7.  
CSS
Expand|Select|Wrap|Line Numbers
  1. #container
  2. {
  3.   width:300px;
  4.   height:500px;
  5.   margin-left:410px;
  6.   margin-top:160px;
  7. }
  8. #container h2
  9.  clear:both; margin:0px 0px 50px 0px;
  10. }
  11. #container table
  12. {
  13. clear:both;
  14. }
  15.  
Jan 2 '12 #10
drhowarddrfine
7,435 Expert 4TB
@JnrJnr - I still don't see anything different.
Jan 2 '12 #11
danp129
323 Expert 256MB
You can try adding the following style at the beginning of your CSS, but I would recommend searching for a reset CSS file and referencing it before any other linked CSS files:

Expand|Select|Wrap|Line Numbers
  1.     h1,h2,h3,h4,h5,table,div,td,tr,span,body,form,p,img,iframe {
  2.         margin: 0px;
  3.         padding: 0px;
  4.     }
  5.  
Jan 20 '12 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: TABOUT | last post by:
Hello, The code which I have attached below properly has the margins working in Portrait mode. The margin is contained in an object called settings. The behavior is that the top and bottom...
0
by: Ned | last post by:
I am having trouble with a layout that I am trying to convert from table based layout to css based layout. I have included source code for a stripped down version. The problem is that when the...
0
by: Linda Antonsson | last post by:
Hi, I am trying to put together a CSS-based layout consisting of a header, a sidebar and a main content area. Page: http://www.westeros.org/ASoWS/ CSS:...
8
by: lkrubner | last post by:
Am I wrong, or do paragraphs have extra space on top in FireFox, when compared to Microsoft IE. The top of this page is an example: http://www.publicdomainsoftware.org/index.php?pageId=299 The...
3
by: typingcat | last post by:
First, thank you for my previous post. But I'm afraid that I've returned with a more picky question. http://cat3.dotnet29.hostbasket.com/korean/ This page looks as I intended on Microsoft...
24
by: JB | last post by:
Hi All, This is doing my head in! Please help. I've built a simple <ul> to serve as a menu for a page I'm working on. I have tested the menu in Mozilla Fireworks 1.5 and it's fine - nice and...
14
by: arteccentrix | last post by:
Please bear with me as I am new to both Firefox and CSS. I have browsed through a number of groups looking for similar problems to my own but can't find a definitive answer. If anyone here can help...
1
by: terrybali | last post by:
Hi Guys I am new to forum and nontechnical. My site has several large flash files. I am looking for someone who can help us solve two problems. Willing to pay whatever normal rate is for this...
0
by: Bouzy | last post by:
I have a problem that I know gets asked about a lot. Its how my page differs in IE vrs. Firefox. I know IE sucks, but hears whats going on. IE......
8
by: luftikus143 | last post by:
Hi there, I recently upgraded to Firefox 3 and suddenly my Ajax.Updater doesn't work anymore. Firefox gives me a "Security Error"... I am using the recent versions of prototype and script.xx.us. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.