我有一个 div,当我的页面第一次加载时,它离顶部大约 100 像素(它包含页面的一些按钮等)。
当用户滚动通过它时,我希望 div“跟随”用户,因为它附加到屏幕顶部。当用户返回页面顶部时,我希望它回到原来的位置。
Visualization - xxxxx is the div:
Default (page load)          User vertically scrolled well past it
---------                    ---------
|       |                    |xxxxxxx| < after div reaches top of screen when
|xxxxxxx|                    |       |   page is scrolled vertically, it stays
|       |                    |       |   there
---------                    ---------