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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:07:57+00:00 2026-05-29T09:07:57+00:00

I have a wrapper positioned to center with an y-repeated background image: <body> <div

  • 0

I have a wrapper positioned to center with an y-repeated background image:

<body>
    <div id="wrapper">
        ...some content
    </div>
</body>

#wrapper{
width: 900px;
margin: 0 auto 0 auto;
background-image: url(image.jpg) 250px 0px repeat-y;
}

Problem: when the window size is higher than the wrapper’s height inherited from its content, the image obviously doesn’t repeat on y-axis all the way to the bottom of the window.

I’ve used jQuery to dynamically apply inline CSS style to the wrapper according to actual document height (when DOM is ready and on window resize event):

$(function(){
    $('#wrapper').css({'height':($(document).height())+'px'});
    $(window).resize(function(){
        $('#wrapper').css({'height':($(document).height())+'px'});
    });
});

The problem with this approach is that every time one extends the window height to a size larger than the previously resized largest size, the document height extends by this difference, essentially making the wrapper DIV infinite if you keep resizing the window infinitely and have a infinite vertical display space.

On a typical 30″ inch display with 1600px height, when user opens the website with a window height 1000px and wrapper is 800px high, the jQuery above sets the height to 1000px tiling the background image correctly. At this point, once the user extends the window size to e.g 1400px, the 1400px is a new document size “remembered default” and doesn’t update itself even if the user resizes his window back to the original 1000px height, adding 400px to the scrollbar height at the bottom.

How to fix this?

UPDATE: (window).height doesn’t seem to work, because window height is a viewport height. When your viewport is smaller than the content and you scroll it, the wrapper always stays the size of the viewport and doesn’t extend to the bottom of the current viewport position.

  • 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-29T09:07:58+00:00Added an answer on May 29, 2026 at 9:07 am

    I figured it out myself with the help of someone’s answer. But he deleted it for some reason.

    Here’s the solution:

    1. remove all CSS height hacks and 100% heights
    2. Use 2 nested wrappers, one in another, e.g. #wrapper and #truecontent
    3. Get the height of a browser viewport. IF it’s larger than #wrapper, then set inline CSS for #wrapper to match the current browser viewport height (while keeping #truecontent intact)
    4. Listen on (window).resize event and ONLY apply inline CSS height IF the viewport is larger than the height of #truecontent, otherwise keep intact

      $(function(){
          var windowH = $(window).height();
          var wrapperH = $('#wrapper').height();
          if(windowH > wrapperH) {                            
              $('#wrapper').css({'height':($(window).height())+'px'});
          }                                                                               
          $(window).resize(function(){
              var windowH = $(window).height();
              var wrapperH = $('#wrapper').height();
              var differenceH = windowH - wrapperH;
              var newH = wrapperH + differenceH;
              var truecontentH = $('#truecontent').height();
              if(windowH > truecontentH) {
                  $('#wrapper').css('height', (newH)+'px');
              }
      
          })          
      });
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wrapper div with a height of 600px and a width of
I have a wrapper div that contains arbitrary content (I don't know its length).
I have a main wrapper div that is set 100% width. Inside that i
I have a div with background image which contains 3 colors of the same
I have such structure (divs): #content-wrapper-> #left #center #right #footer #footer { position: relative;
I have an empty div called #lightPole that has a background image of a
I have a wrapper div which is positioned absolute. Is it possible to extend
This shouldn't be hard...I have a menu and some content wrapped in a centered,
I have a header div as the first element in my wrapper div, but
I have articles with display:table and an image wrapper inside with display:table-cell to achieve

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.