Change div css when user scrolls past it, using jQuery

后端 未结 3 1500
天涯浪人
天涯浪人 2020-12-16 07:54

When a user scrolls past a div I need it\'s css changed to position:fixed. Much like what is done here: http://imakewebthings.com/jquery-waypoints/shortcuts/sticky-elements/

3条回答
  •  一生所求
    2020-12-16 08:22

    I noticed in your answer #this disappears abruptly once you get down to #footer. I've tweaked your answer to allow for #this to stick to #footer and scroll which is a lot smoother.

    My demo uses slightly different markup and is a little more verbose so jump over to jsFiddle and check it out.

    Demo: jsfiddle.net/Marcel/e9hyw/

提交回复
热议问题