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

How can I achieve this effect?

Basically I want to achieve a certain effect on my website when you scroll. For example look at this page: http://jelly.co/press . On the desktop version, when you scroll the nav bar gets smaller, how can I achieve a similar effect?

2 Answers

The easiest way to achieve something like this would be to use javascript to trigger an event on page scroll. There are some useful libraries that could help you out here such as jQuery Waypoints.

jQuery Waypoints is pretty robust, the tradeoff of course is that it's not the simplest way to add the "on scroll header" effect.

You can't do that with CSS, it takes jQuery. Here's a working demo: http://jsfiddle.net/jezzipin/JJ8Jc/

Another option that looks pretty simple to implement as it just does the on scroll header is: https://github.com/weare2ndfloor/HeadShrinker