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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:10:26+00:00 2026-05-25T19:10:26+00:00

Here’s a link to what I’ll be referring to. I’m having some trouble getting

  • 0

Here’s a link to what I’ll be referring to.

I’m having some trouble getting the background image to work the way I’d like it to.

I want the background to auto resize based on the width of the window, which it is already doing correctly. If you make your window smaller you’ll see the background shrink with it.

Here’s the issue. If you make your window wide (short) then the background will resize and go too high so you can’t see the top of the background anymore (since the background is bottom positioned).
I want the background to be top position when you are at the top of the page, and as you scroll down it will slowly move to be bottom positioned. Sort of like the effect of an Android phone’s background when you move left and right. Of course, keep in mind that I still want the background to auto-resize when you make the window smaller.

html {
  background-color: #70d4e3;
  height: 100%;
}

body {
  height: 100%;
}

.background {
  margin-top: 45px;
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: -9999;
}

.banner {
  margin: 0px auto;
  width: 991px;
  margin-bottom: -9px;
}

.content {
  background: url("http://i.imgur.com/daRJl.png") no-repeat scroll center center transparent;
  height: 889px;
  margin: 0 auto;
  width: 869px;
}

.innerContent {
  padding: 30px;
}
<img src="http://i.imgur.com/6d5Cm.jpg" alt="" class="background" />

<div class="banner">
  <img src="http://i.imgur.com/JptsZ.jpg" alt="" />
</div>
<div class="content">
  <div class="innerContent">
    testing
  </div>
</div>

Maybe some javascript or jquery would be needed to achieve this.

  • 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-25T19:10:26+00:00Added an answer on May 25, 2026 at 7:10 pm

    Well, this was fun, thanks!

    I hope you don’t mind me taking the liberty to use percentages to make my life a little bit easier and possibly the script slightly more robust since I can reliably use floats with percentages.

    What I did is make the layout, html and css comply with the rules you need for the bg to be animated properly, they stayed largely the same from what you had.

    Then it was just a question of figuring out the calculations needed with the right properties to figure out the percentage you were from the top, the *20 is actually the amount of space ‘left’ to fill by the background image in percentages (as the background height is 80%).

    They I moved the calculations to a function so I could call that on scroll and on window resize, making sure it’s initiated on any event that modifies the window somehow…

    Didn’t do extensive testing but it worked in Chrome and I’m tired :p

    I believe this is what you are looking for:

    http://jsfiddle.net/sg3s/RSqrw/15/ See edit 2

    If you wanted this the other way arround just make the page background start at the top and modify that:

    http://jsfiddle.net/sg3s/RSqrw/14/ See edit 2

    Edit:

    As a bonus, and since I had never actually written jquery script as a ‘plugin’, I decided to convert this into one. What I came up with should be easy to implement and use!

    http://jsfiddle.net/sg3s/RSqrw/52/ See Edit 3

    Functionality successfully tested in Chrome, Firefox 3.6, IE9 + compatibility mode

    Edit 2:

    Reading the question again checking if I did it right I noticed I didn’t quite do what you want, so I updated the link in the first edit which gives you a plugin in which you can have several options for the scrolling background. It retains my ‘old’ interpetation while also doing what you want… Read comments in code for some extra descriptions.

    Edit 3:

    As I went to work today I was bothered with the fact that my plugin ‘try’ was a little bloated. And as you mentioned in the comment it didn’t quite fit the requirements.

    So I rewrote it to only do what you want and not much more, tested in Chrome Firefox, IE9 +compat etc etc.. This script is a lot cleaner.

    http://jsfiddle.net/sg3s/vZxHW/

    You can chose to make the background stick to the top or bottom if the height fits in the window. Nothing else, but that is already more than enough to do some pretty cool stuff :p

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

Sidebar

Related Questions

Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is my work environment: Eclipse Juno as IDE with maven2 plugin on it
Here's what I'm doing. I want to upload multipart file via Ajax to my
Here's what my table TheTable looks like ColA | ColB | ColC ------+-------+------ abc
Here are some facts about my app followed by a question My app has
Here is the issue I am having: I have a large query that needs
Here's a coding problem for those that like this kind of thing. Let's see
Here is an object that I'd like to use with ng-repeat, but it's not
Here i have gridview which contain some values retrieved from database.We put radiobutton list
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }

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.