So, for some reason my site has horizontal scroll which is annoying. I have divs set to 100% and margin:0 auto;, but I’m guessing that its because of padding, borders, or margin making it go beyond 100% width?
a BLOCK level element is 100% width by default. You shouldn’t declare 100% width unless the situation demands it.
Also, by declaring 100% width you make padding/borders become ADDED to the calculated width. In other words, width:100%; padding:1em= 100%+2em.
So in this case #Footer, which is already 100% the width of your body , gets 2 additional ems of padding and on top of that since you made your body be the width of the screen ( width 100% then the screen must grow bigger than itself (thus the scroll bars)
Try taking the horizontal padding of #Footer and see if it help. Do note that you may have other places in your code in which you are doing the same thing, the easiest solution is NOT to declare width:100% ; for block elements.
and I likes that. I may go back and try Dresden’s solution because it seems like the best way to do it. The ralph.m way seems to shrink my content some and no one likes shrinkage.
The border box solution returns us to the box model we should always have had (one of the few things IE was right about, even though it was wrong about it, too!)
If you are seeing shrinking, maybe consider adding back some padding where you want it. The layout looked fine to me with the code applied.
The only thing to remember is that it is only IE8+ compatible as ie7 and under don’t understand box-sizing as such (although they do revert to thatborder-box mode lin quirks mode).
An added benefit to using the box-sizing rules is that suddenly form elements are easier to handle because presently some elements (like select) already use the border-box model while others like inputs do not and you end up with inconsistent sizes when using the same dimensions.
Ralph I just added the code back that you suggested. The problem is/was that it made my footer circles ovals and…Well, I fixed the other issues which were just things that I could correct. Overall I like the fix.