
Originally Posted by
kanjigirl
I'm working on a website that looks fine in IE and mostly fine in Opera. However, in Mozilla Firefox and Netscape 8.0 the content boxes are showing up incorrectly.
Your site is being rendered by Firefox exactly as your style sheet says it should.
The width of a box is calculated using the following equation:
Code:
box width = margin-left + border-left-width
+ padding-left + width + padding-right
+ border-right-width + margin-right
Substituting in the values from your style sheet, and replacing auto values as described (see link), we get for content_right:
Code:
box width = auto + 0 + 12 (px) + 200 (px) + 12 (px) + 6 (px) + auto
= 0 + 230 + 0
= 230px
and for content_middle_black:
Code:
box width = auto + 6 (px) + 5 (px) + 575 (px) + 5 (px) + 6 (px) + auto
= 0 + 597 + 0
= 597px
You limited the width of wrapper to 775px, and the sum of those widths clearly exceeds that value, so the contents shift as they're required to.
So, why does it appear to be fine in IE and Opera? Microsoft got the algorithm badly wrong in previous versions of IE, and made the content width (width, above) the only significant factor in calculating the box width. If you place IE6 in Standards mode by including a complete DOCTYPE (you omitted the URL), you will see something similar to what Firefox renders. The same with Opera which tries to emulate some of IE's buggy behaviour when it thinks it will be necessary.
This problem is commonly referred to as the box model bug, and has several solutions. Essentially they all require you to put browsers into Standards mode by changing the DOCTYPE (in your specific case) to:
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
and then tricking older IE versions into rendering correctly usually using the box model hack (see the first result in the previous link).
Good luck,
Mike
Bookmarks