Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6853901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:34:02+00:00 2026-05-27T01:34:02+00:00

I thought this would be a common question, but I didn’t find it anywhere…

  • 0

layout situation

I thought this would be a common question, but I didn’t find it anywhere…

A fixed width layout, centered to the browser window. Behind it, a background that is also centered.

The background should not cause a horizontal scrollbar. The content box should.

I cannot set the background to the body element, because that would mean the background stays centered relative to the browser (and therefore “move” relative to the content when the browser window is too small to contain the whole content box).

If I don’t set it to the body, anything that would be able to “contain” the whole image, would also cause a scrollbar… isn’t it?

Is javascript really my only hope?


EDIT:

It seems like I didn’t explain myself well enough.

This is what I want:

(highlighted area represents the browser window)

1 – no scrollbars, background sticks to content

notice that there are no scrollbars.

2 – scrollbar for content, background sticks to content

there is a scrollbar on the browser for the content

This is what I get

1 – background centers to window

If set to body, the background centers to the window and therefore doesn’t align to the content.

2 – background causes scrollbars

If I set the background to an element, it causes a scrollbar on the window and therefore, when resizing the browser, the content doesn’t stay centered as long as it should.

Answer

like the accepted one below, but with this code

#myBackground {
    background: url("img/background.png") no-repeat scroll center 0 transparent;
    height: 6000px; /*height of the background*/
    min-width: 950px; /*width of the content box*/
    position: absolute;
    width: 100%;
    z-index: -1;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:34:03+00:00Added an answer on May 27, 2026 at 1:34 am

    I would use a DIV that is the immediate child of the body with position:fixed

    #myBackground
    {
      background-image: url(myBackground.jpg);
      position:fixed;  
      width:100%;
      height:100%;
    }
    
    <div id="myBackground"></div>
    

    position:fixed support is lacking in older versions of IE and with the newer versions, you need to force IE to use a more modern doctype for it to handle position:fixed properly. Try this as the very first line in your HTML:

    <!doctype html>
    

    One question, do you need a “fixed” background or is that something I’m assuming? If you want the background to scroll with the rest of the content, replace position:fixed with position:absolute and forgo the HTML5 doctype if you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question seems like it might be somewhat common, but I didn't find anything
I thought this would be a pretty common question to look for in Google
I thought this could've been a common question, but it has been very difficult
This is probably a very common question, but I was unable to find an
I thought this would be simple, but its not working .. in both the
I thought this would be fairly easy, but I'm totally baffled. I want one
I thought this would be pretty easy but I'm running into all sorts of
I would have thought this would be an easy one to Google, but I've
Okay at first I thought this would be pretty straightforward. But I can't think
I thought this code would work, but the regular expression doesn't ever match the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.