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 7569223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:06:54+00:00 2026-05-30T15:06:54+00:00

i want a background image that is larger than the content, which will remain

  • 0

i want a background image that is larger than the content, which will remain centered with the content, but will not affect the layout (meaning no scrollbars to accomodate the background image). the content must be centered using margin: auto; so that the left side will remain flush with the left side of the viewpane, when the viewpane becomes smaller than the content.

I have seen this question asked several times, and have tried quite a few solutions, but none of the accepted answers have actually worked.

Edit to Clarify

This question is still a bit murkey, so I will attempt to clarify with some images showing what I need. In these images, green is the background image, red is the main content, and blue is the browser’s viewpane.

enter image description here

A: When the viewpane is smaller than both the background image and the main content, the left side of the content remains flush with the left side of the viewpane, the background image remains centered to the main content, the viewpanes scrollbars will only scroll out to the right edge of the main content (and not to the right edge of the background).

B: When the viewpane is larger than both the background image and content, both remain centered to the viewpane.

C: When the viewpane is the same size as the main content, the background image should remain centered to the main content, no scrollbars should be present.

  • 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-30T15:06:55+00:00Added an answer on May 30, 2026 at 3:06 pm

    Updated Answer: I still have spent way too much time on this :-), especially when it ended up so simple. It allows for a background to be sized based on the height of the container, which seems to be different than yunzen’s solution. Now does use margin: 0 auto;. Still grows with container height.

    View the new answer.

    You can view the original, more complex answer which does not use auto margin.

    HTML:

    <div id="Bkg">
       <div id="Content">Content goes here. </div>
    </div>
    

    CSS:

    #Bkg {
        width: 100%;
        min-width: 300px; /* equals width of content */
        background:url('http://dummyimage.com/400x20/ffff00/000000&text=Center') repeat-y top center;
        padding-bottom: 50px;
    }
    
    #Content {
        width: 300px;
        margin: 0 auto; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to set a background image for a div, in a way that
I have a tiling background image, but I want to overlay another tiling image
I have an image that I want to use as the background for every
I have a css background image that I want in front of my img
This is the background image that I want to show as the full body
I want to center a background image. There is no div used, this is
I have a web page where I want to switch the background image of
Ok so I have a Background background-image: url('images/body.png'); now I want to overlay a
i want have an image and i want to set it as a background
I've asked this question before : CSS Background Image Its not as such a

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.