CSS: background image does not fill when scrolling

I had the same problem and it is annoying. Problem for me was that I could not change the HTML, only the CSS, so I couldn’y remove the additional divs.

The problem as I see it is that the backgrounds have “width: 100%” and the container has “width: 900px”. So, for example, if the browser window is 800px wide, the backgrounds are set to 800px and, therefore, when you scroll the window horizontally, you get the areas without the background.

Another way to fix the problem is to remove the “width: 100%” from the backgrounds and replace it with a “min-width: 900px”, thus forcing the backgrounds to be always at least the same width as the container. When the window size becomes less than 900px, the backgrounds always remain at the same with as the container. Works a treat.

Leave a Comment