Welcome to the Treehouse Community
Looking to learn something new?
Jeff Lemay14,266 Points
How do you make a div be fixed at the top only after scrolling to a certain point?
I've seen a few sites recently where, after scrolling down the page a bit, a section will reach the top of the page and then stay fixed at the top so you can always see it as you continue scrolling down.
One example is the Yahoo! homepage; there's a purple section with News categories (All Stories | News | Local | etc.). It sits like 400px down the page, but when you scroll down to it, it becomes fixed at the top as you continue scrolling past.
I'd like to implement this in something I'm working on, but I don't know what's being used. I can see that the CSS changes once the item becomes a fixed section, but how does the CSS recognize that you've scrolled that far?
PS: Treehouse is awesome, couldn't be happier with the service.