CSS Double padding IE7 Fix
Nothing is more annoying than finishing a web design, having it dispay just the way you like it in your standards compliant browser (*cough* download Firefox) only to remember to check it in IE and find it a garbled mess. Today I came across a rather annoying CSS bug in IE7. IE7 doubles the top padding on my navigation menu.
CSS Code
#nav {
clear: left;
padding: 16px 0 0 30px;
}
And the fix…
Just add display: inline-block to the div with double padding. That’s it… I know, it’s ridiculous.
#nav {
clear: left;
display: inline-block;
padding: 16px 0 0 30px;
}
*UPDATE* If you want a more detailed explanation of the issue, go to: Position is Everything
*UPDATE 2*There are some scenarios where this might not be the best solution. Read through the comments below if you run into any issues.
Roxana 6:49 pm on December 11, 2011 Permalink
THANKS a LOT. I was having a headache with this issue until your solution was the fix. THANKS A LOT!
Ond?ej Ĺ eliga 7:10 pm on January 3, 2012 Permalink
Men, thats great! Thanks a LOT, I allready thought it’s impossible.
Dileep 10:02 pm on January 3, 2012 Permalink
This one posted before six years.. But still worthy for web developers..Great !! Thanks !!
Shai 8:58 am on January 10, 2012 Permalink
simple and clear :-)
Dennis 10:07 am on February 7, 2012 Permalink
AWESOME!!! THANKS so much!
saravanan 3:38 am on February 13, 2012 Permalink
if title name is big,there is no bottom space.. i need both top and bottom have same pixel
Martin Tsanev 1:54 pm on February 27, 2012 Permalink
great man! thanks a lot
Alex 4:41 am on May 3, 2012 Permalink
Just AMAZING!
marlon 8:59 am on May 8, 2012 Permalink
no, im using IE9 (setting browser/document mode to IE7) and tried to put the style that u mentioned as a conditional comment and a hack… besides, im using IEtester application for checking this… not works :(
Victor 3:46 am on May 12, 2012 Permalink
Thanks a lot!!! you’re right the post is quite old but you help a lot of people including me!
ie is allways a pain in the ass dealing with css
Victor 3:52 am on May 12, 2012 Permalink
#marlon Are you sure you did as he said? ’cause I tryed IE9 with those settings and It’s still working in my case (a div within a div). take a look again to make sure you didn’t type that hack well.