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 CSS Layout Basics Positioning Page Content How Z-index Works

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,736 Points

What does the 'sticky nav' plugin do that is different from doing it with CSS (fixed position, z-index)?

I think I'm learning things out of order. I learned to do the sticky nav plugin, and now I'm learning how to basically do the same thing with CSS. Why did they make the sticky nav plugin if it's so easy to do it without JavaScript?

way more cool things to do with the sticky nav plugin and much easier

2 Answers

Eduard Zabara
Eduard Zabara
2,613 Points

I guess one reason is because JavaScript allows you to add animations on scroll, which you can't with only css.

Adam Hill
Adam Hill
7,492 Points

It is easy to do with css and you can add some basic animation etc, but using JavaScript plugins allows you to do extra things like tell the nav to become sticky only after you've scrolled past a banner, or start at the bottom of the window (on screen but below a banner) and then smoothly scroll to become a fixed top header. Also it used to be harder to do everything with css, and still can be if you're trying to support older browsers.