Forum Moderators: not2easy
I was curious how I can fix the bug with CSS Padding and FireFox. If I specify padding-top: 15px; It works great in IE but FireFox will pad the top and bottom. Is there a way I can only pad the top in FireFox while making it still compatible with IE?
Thanks in advance for your help!
Wes
How can I fix the CSS padding problem?
This is the CSS:
.blue_box_boxhead h2 {
background: url(http://www.mysite.com/images/mn_box_hdr_l.gif) no-repeat top left;
margin: 0;
padding: 7px 0px 0px 10px;
color: #FFFFFF;
font-weight: bold;
font-size: 14px;
height: 29px;
}
padding: 7px 0px 0px 10px;
font-size: 14px;
height: 29px;
So, height - top padding = 22px remaining
22px - font-size = 8px remaining
That 8px is what you think is your bottom padding. At least, I think that's what's happening. Here's a diagram to help explain:
+-------------
¦````````````^
¦````````````¦
¦````````````¦ 7px
¦````````````v
¦``¦\````¦```^
¦``¦`\```¦```¦
¦``¦``\``¦```¦ 14px
¦``¦```\`¦```¦
¦``¦````\¦```¦
¦````````````¦
¦````````````¦
¦````````````v
¦````````````^
¦````````````¦ height - padding - font size
¦````````````¦ 29px - 7px - 14px = 8px
¦````````````v
+-------------
padding: 7px 0px 0px 10px;
font-size: 14px;
height: 29px;
So instead, that would look more like this:
+---------------------
¦````````````^
¦````````````¦
¦````````````¦ 7px
¦````````````v
¦``¦\````¦```^```````^
¦``¦`\```¦```¦```````¦
¦``¦``\``¦```¦ 14px `¦
¦``¦```\`¦```¦```````¦ 29px
¦``¦````\¦```¦```````¦
¦````````````¦```````¦
¦````````````¦```````¦
¦````````````v```````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````v
+---------------------
+---------------------
¦````````````^
¦````````````¦
¦````````````¦ 7px
¦````````````v
¦``¦\````¦```^```````^
¦``¦`\```¦```¦```````¦
¦``¦``\``¦```¦ 14px `¦
¦``¦```\`¦```¦```````¦ 29px
¦``¦````\¦```¦```````¦
¦````````````¦```````¦
¦````````````¦```````¦
¦````````````v```````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````¦
¦````````````````````v
¦````````````^
¦````````````¦
¦````````````¦ 10px
¦````````````¦
¦````````````v
+---------------------
;)
Anyone else use this method?
frequently... it's called the Box in a Box method of the "box model" hack and is generally the easiest way to get to grips with the Box Model regardless of Quirks or Strict rendering Modes. Is very useful when using container divs for columns that might need to be precisely dimensioned in order to help a layout remain stable.
it can be simplified too in some cases by just using the container div and then padding/margining all the elements inside it, <p>, <hx> etc.. but for ease inserting a secondary (nested) container allows flexibility later even if not used initially
Many CMS/Blog software templates have this built in and though it is often touted by hand coders (me included) as extraneous code it is very useful ;)
Suzy