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 Navigation scroll effect

I have seen on some pages that they have one kind of navigation bar at the top of the page that is in a static position but then when you scroll it fades for like 2 sec and then comes back as if it was fixed top and it has another design to it. I hope you understand what I'm trying to explain. If you know how please answer with the code and explain how it works. That would be lovely thanks.

Regards, Nils <3

2 Answers

Austin Whipple
Austin Whipple
29,725 Points

The video Henrik is referencing is Add a Sticky Navigation Bar and uses the handy Sticky JS plugin.

It's not overly complicated to do on your own by toggling classes with JS based on scroll position and then applying alternate CSS and transitions to those two classes, but that plugin is definitely a great way to start.

Thank you!!