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

  • Home
  • SEARCH
  • 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 7673183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:27:08+00:00 2026-05-31T16:27:08+00:00

I have a wrapper div that contains arbitrary content (I don’t know its length).

  • 0

I have a wrapper div that contains arbitrary content (I don’t know its length). How can I put a background image that stretches its whole length since background-images doesn’t stretch?

I’ve tried with a div containing a img tag. The div has a lover z-index that the rest of the content and has position: absolute. The problem is that the image is longer that the content and so it just makes it longer (the wrapper has overflow: auto).

<div id="wrapper">
    <div id="image-wrapper" style="position: absolute"><img src="bg.jpg"></div>
    [.. OTHER CONTENT ..]
</div>

If I set the div and the image’s width and height to 100%, it takes the window’s height, not the wrapper’s.

Any help?

  • 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-31T16:27:09+00:00Added an answer on May 31, 2026 at 4:27 pm

    background-size is available since CSS3:

    #image {
      background-image: url("bg.png");
      background-size: auto;
    }
    

    auto is the default value and does not stretch the image.

    You can set the width and height manually:

    #image {
      background-size: 100% 100%;
    }
    

    or

    #image {
      background-size: 500px 300px;
    }
    

    The alternative: background-size: contain and background-size: cover.

    contain stretches the image so that the image is as big as possible but completely visible within the element, whereas cover stretches the image to 100% width, regardless if the image is cropped at the top and/or the bottom.

    But the different browsers are not completely consistent when rendering backgrounds with these keywords.

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

Sidebar

Related Questions

I have a page with a wrapper div which contains a background image and
I have a wrapper class that contains all the content on the web page.
I have a main wrapper div that is set 100% width. Inside that i
i have a requirement in which i have a container div that contains 3
I have a #wrapper div and a #grid div nested inside. currently I can
I have a div that contains many floated child items. Each child item is
I have a problem using fadeIn() on div that contains elements which positions are
I have a wrapper containing an inner wrapper, and that inner wrapper contains 2
I have a wrapper element that contains two floated elements the contentArea and sidebar.
I have a form that's wrapped in a div with id content : <div

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.