div 在滚动期间在位置:固定和位置:绝对之间移动
我正在寻找一种方法来模仿该网站左侧菜单的行为: http://www.nectarboutique.com/collections/on-sale
含义:我需要必须绝对定位(CSS 样式)靠近页面顶部的 div,直到用户向下滚动超过某个点,然后它更改为 position:fixed
。然后,当它到达底部附近的某个位置(在与页脚相交之前)时,它必须变回 position:absolute
。
如果有人知道解决方案,这对我有很大帮助?
I am looking for a way to imitate the behaviour of the menu to the left on this website:
http://www.nectarboutique.com/collections/on-sale
Meaning: I need a div that has to be absolutely positioned (CSS styled) somewhere close to the top of the page, until the user scrolls down beyond a certain point, and then it changes to position: fixed
. Then, when it reaches somewhere near the bottom (before it intersects with the footer), it has to change back to position: absolute
.
This would be a big help to me, if anyone knows a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
他们使用自定义 jQuery 代码。请参阅此处有关如何执行此操作的好教程:
http://css-tricks.com/scrollfollow-sidebar/
或者你可以下载一个 jQuery插件可以帮助您:
http://plugins.jquery.com/node/8152
They are using a custom jQuery code. See a good tutorial on how to do this here:
http://css-tricks.com/scrollfollow-sidebar/
Or you could download a jQuery plugin to help you on your way:
http://plugins.jquery.com/node/8152