Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background image cut off beyond viewport

Url for the unruly site: http://chrism.se

After we put it live we discovered that if the viewport is too small for the content, so as to require scrolling, the background image (body-tag, repeat-x) won't extend beyond the initial view, but I can't for the life of me figure out why and how to fix it. A note to bear in mind is that I didn't code the site by myself, since I'm not that Javascript-savvy and the designers wanted some swooshy effects. My senior colleague could surely find a remedy, but he is unfortunately away and I'd like to wrap this up.

The state of the html and css is the same as when I found out about the issue, but I've tried suggestions I've seen on similar questions, mainly revolving around min-width. I don't really understand the difference between background is only as wide as viewport? and my problem?

Full view = i.imgur.com/6aDpN.jpg

Problem = i.imgur.com/X6JVp.jpg

like image 591
Cederfjard Avatar asked Jan 24 '11 13:01

Cederfjard


3 Answers

IE does not support min-width so you can use an expression to do the same:

body {
    /* fix for most browsers, fill in desired width */
    min-width: 1000;

    /* IE Version, fill in desired width equal to the min-width, second value with 2px less */
    width:expression(document.body.clientWidth < 1000 ? "998px" : "auto" );
}
like image 116
Daniël de Wit Avatar answered Nov 18 '22 19:11

Daniël de Wit


The closest thing to a working solution I could find was to from #bodyCurrent, #bodyNext:

  • Remove right: 0.
  • Add min-width: 1349px.

Looking again, maybe that's good enough.

Tested in Firefox only, using Firebug.

like image 20
thirtydot Avatar answered Nov 18 '22 18:11

thirtydot


I realize I'm way late to the party, but I ran into the same problem and added a min-width to the body to fix this problem. Since the link you provided still has this problem, I assume you may want more advice. The min-width of the body should be at least as wide as the viewport when horizontal scrollbars appear.

It's easier to see what's happening if you make your viewport small enough for scrollbars and use Firefox's 3D view to see the page. Then you'll see that your region-footer is set to take 100% width of the body element and that the background works fine; however, the body itself is smaller than the overflow from the top part of the page so you get that cut-off looking area when you scroll. So make the body element have a min-width as large as the overflow from the top part of the page and you'll be all set. This is a pretty common problem (I even noticed it on mailchimp for a while).

like image 1
TorranceScott Avatar answered Nov 18 '22 20:11

TorranceScott