views:

271

answers:

2

Hello!

I have a horizontal bar that has been given a width of 100%. Within the horizontal bar, I have text that is left-aligned within a 978px container. Whenever the browser window is shrunk so that it is less than 978px wide, a scrollbar along the bottom of the page appears. Whenever I scroll to the right, the bar no longer spans the width of the page but instead, is left behind. I understand why this happens, but I don't know what to do to fix it. If you have any ideas, let me know. Thank you!

An example page

+1  A: 

well, you have #header set to 100% of it's containing block (which would be the body). When you shrink the body, the header's width shrinks. If the body's width is less than the container's width, the black bar will not extend the whole way.

What exactly would you rather it did?

-not have a scroll bar: take out the container, center the text using #header

-the black bar expands the whole distance: The easiest way to solve that is to give the container a background-color.

cofiem
"give the container a background-color" is exactly what I thought of.
strager
Though this works for the example I provided, it doesn't work within the context of my website. The reason for this is that I use the container class multiple times throughout my code. However, it isn't supposed to have a gray background multiple times.
John
What do you do when it doesn't have a background? If it's different colours, you could just use multiple css classes.
cofiem
Cofie, that's what I ended up doing =/Wanted to know if there was a better way.
John
A: 

Change:

width: 978px;

to:

max-width: 978px

That seemed to do the trick in FF3, IE7 and chrome.

Chris Missal
Though this works for the example I provided, it doesn't work within the context of my website. The reason for this is that setting my "wrapper" to have a max-width and not a width causes parts of my page to shrink when I don't want them too if the browser window is too small to contain them.
John
A better way to word that: the page never scrolls if max-width is set... it just keeps shrinking. I want it to scroll.
John
@John, Perhaps set min-width as well?
strager
No other acceptable min width would help.
John