tags:

views:

155

answers:

3

OK I have backgrounds set up like this:

HTML

<div id="container">
    <div id="content">
    CONTENT HERE
    </div>
</div>

CSS

#container
{
    background:url(image.gif);
}
#content
{
    width:800px;
    margin:auto;
}

So the idea is for the content to be within an 800px box, while the background for the content spans 100%, I have this same setup for different area like the header, footer, and main portions of the page. So they all haver different backgrounds spanning 100% while the content is all within an 800px box.

All this works fine, until you make the window small enough to show a horizontal scrollbar, then when you scroll horizontally, the revealed portion no longer has a background, yet if you make the page wider, then the background IS there.

You can see it here: Clicky

Is there a way to fix this?

Thanks!!

A: 

Since you are using a fixed width content area why not give your #container (actually #inner_content_container on your site) a fixed width also? Since your image is 824px wide I just used FireBug to make your container that width and your problem goes away.

NOTE: When you do this you will need to give the container an auto margin too and set overflow to hidden if you don't want scroll bars..

#container {
  margin:auto;
  overflow:hidden;
  width:824px;
}
Randy Simon
That would make the viewport have to be 824 wide to not show scroll bars, I want people with 600x800 res not to still have horizontal scrollbars when maximized. But you did give me an idea that fixed it, for the header and footer, I set the content to have the same background as the container, and for the main section I just set it to have a white background. This fixed it :)
John Isaacks
I think you could have also used overflow:hidden (I updated my answer). Either way, glad you got it working.
Randy Simon
A: 

As I understand you need to show the background adverts even when the browser is smaller than 800px.

You could set a min-width on #container - make it a bit bigger than the #content box so the browser will get scrollers based on container div not on content anymore.

#container {
background:url(image.gif);
min-width:960px;
}

Note: min-width is not supported by IE7/6, but there are workarounds to make it work there.

easwee
A: 

I figured out (or it seems) that when you scroll, only #content's background is "revealing" not #container's background. So what I did was set #content to also have the same background as #container This fixes the problem without having to make the scroll bar appear for non-content.

John Isaacks
Mark question solved than.
easwee
@easwee you cannot accept your own answer until it has been 2 days since you asked the question. I would also prefer to mark someone else's answer rather than my own. So I would like to give someone the opportunity to either give a better answer than mine or expand on my answer so I can mark them instead. :)
John Isaacks