• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Proper way to use CSS padding?

igowerf

Diamond Member
Firebird and IE seem to handle this differently.

#bla {
width: 800px;
padding: 15px;
}

In IE, I'll have an 800px wide container with 15px of padding on the inside on all 4 sides of the container. In Firebird, I get an 830px (800 + 15 + 15) wide container. Apparently, IE is, once again, dumb because the W3C states that the padding is supposed to be added to the width. :\
 
I had a bitch of a time getting something like this to work earlier today. The IE way is much more convenient when you have 5 columns that are each supposed to be 20% width. Using the correct method, they're each 20% plus 30 pixels, and they don't fit. I ended up having to nest two <div>s inside each other to get it to work.
 
better explanation of what I did:

<style>
.out{
width: 800px;
}
.in{
width: 100%;
padding: 15px;
}
</style>

<div class="out>
<div class="in">
text
</div>
</div>

That should give consistent results in both browsers.

(I'm doing this from memory... didn't actually look at the code I wrote earlier, so it could be slightly wrong, but that's general idea)
 
Ah. That makes sense. I'll try that then. Thanks. I don't really like that we have to add extra tags to the structure to get this to work nicely.
 
This is a very well know bug with IE's box model. IE 6 fixes in when running in standards-compliant mode. IE 5.x can be given alternate values to compensate for the bug using various CSS hacks.
 
Back
Top