Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Anyone know how to change the background as the user scrolls?

Hello, I was wondering how to create a static background that would, um... 'slice away' as the content scrolled...? Okay, that was terrible. To get a sense of what I mean check out the Lush Spa page, notice how the background changes as you scroll, and between sections you can see two backgrounds at once. I'm trying to recreate that, does anyone know how?

2 Answers

I believe that there is some Javascript that must be incorporated into your project to obtain that effect. What you are looking for is called a vertical parallax effect. This effect would take some time to explain on the forums, but I assure you that I did some research in order to help you. I found what you were looking for online. Here is a tutorial I found, it also includes a demo. I hope this helped.

This isn't the parallax effect you're asking for, but some simple code to change the background as the user scrolls... jic! :)

http://jsfiddle.net/aXefB/1/

No, this isn't what I'm looking for, your example changes the background suddenly,