I'm building a centered website. The body has a background to give the website a shadowed border. There is a problem when using different resolutions: sometimes I have a 1px-spacing on the rightside of my banner.
I can't figure out, how i can fix this so it looks the same in all screen resolutions.
Oh btw, the problem only occurs in Internet explorer. (tested in FF an IE)
There is no perfect solution. However, you should be able to stabilize the behavior of your background image by making it bigger. Stretch it out to 4000 pixels wide or so. That will make browsers less likely to place it in the wrong location when doing the calculation for centering the background.
I have had this problem before, and it is something to do with the width of the background being even and the layout width being odd... or vice versa. They both need to be even or both odd widths... It sounds really strange, but I'm pretty certain that was the solution.
For example, If your background is 761px wide and your layout is 750px wide, you need to either make the background 760px, so that both are an even width, or make the layout 751px wide, so that both widths are odd.
You don't need a separate div for the background. Just make sure the width of background image is even (if the website width is even) when you chop it up and save it and place the image on the background of the body.
body { background: url(img/bg.jpg) repeat-y 50% 0; }
I recently ran into this problem as well, and fixed it for myself, so I thought I'd share what I did. First off, I don't think the odd/even thing matters, as is expressed here: http://www.positioniseverything.net/bg-centering.html. It appears it's something that IE and FF just don't agree on.
So what I did was use an IE hack (probably frowned upon) to emulate the 1px difference in IE. It looks something like: