简体   繁体   中英

How to make a scroll to fixed div that doesn't stick to the top

I have a side bar like on this demo, that starts at a certain position on the page and as you scroll down it bounces a long with that position. I'd like something like that but without the bouncing.

http://blog.echoenduring.com/wp-content/uploads/demos/echo_ContainedStickyScroll/

The closest I have come are the other scroll to fixed position questions but I don't want my div to have to hit the top of the page to become fixed. How do I do this?

Check the scroll of the page :

if($(window).scrollTop() < somePosition) {
    $("mydiv").css("position","fixed");

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM