I'm trying to create a div that stays fixed on top when a user scrolls down and when he scrolls back up, goes back to the original position.
I need this exact same behaviour that 9gag offers -> http://9gag.com/gag/293756
Thanks!
I'm trying to create a div that stays fixed on top when a user scrolls down and when he scrolls back up, goes back to the original position.
I need this exact same behaviour that 9gag offers -> http://9gag.com/gag/293756
Thanks!
Do the following:
$(window)
.position: fixed
withtop: 0
. You may also need to adjust the left attribute, depending on your layout.position: static
.Use the Jquery Waypoints plugin: http://imakewebthings.github.com/jquery-waypoints/
Extremely easy to implement.
The code that creates exactly the same behavior as 9gag.com: