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

TzeYang Chew
TzeYang Chew
12,039 Points

how do i do this photo parallax effect from this webpage http://highergroundmelbourne.com.au/ below video section

hi, how do i do this photo parallax effect from this webpage http://highergroundmelbourne.com.au/ - below video section/ the photo at purple background

i can only do background attachment { fixed } but its not the same...

1 Answer

Steven Parker
Steven Parker
229,785 Points

You could analyze this with devtools to be sure, but just based on how it looks I'd guess that it's reasonably simple:

The image is probably inside a container element that is smaller than the image, with overflow set to hidden. Then a JavaScript routine is triggered by scroll events that makes slight changes to the image position based on the scroll position.

That page has several nice effects, my favorite was the "flashlight" effect where the sharp circle follows the mouse around an otherwise hazy photo.