简体   繁体   English

如何使用jQuery和顶部栏移动侧菜单

[英]how to move side menu with jquery along with top bar

在此处输入图片说明

How can I make the side menu which is on the right scroll down when the bookmark bar gets to it, and then move along with the bookmark bar with jquery, and not knowing that menu is moving, it's like it stood stay still. 当书签栏到达菜单栏时,如何使右侧菜单向下滚动,然后使用jquery与书签栏一起移动,而又不知道菜单栏是否在移动,就好像它静止不动一样。

You'll need to: 您需要:

  • Watch the $(window).scroll event 观看$(window).scroll事件
  • Check if the users scrollTop at the sidebars .offset().top 检查用户scrollTop在侧边栏.offset().top
  • If so, set the side to position: fixed 如果是这样,请将侧面设置为position: fixed
  • Otherwise, restore it to position: relative 否则,将其还原到以下position: relative

check out this tutorial: Scroll/Follow Sidebar 查看本教程: 滚动/跟随侧边栏

It uses a combination of CSS and jQuery to do what you need. 它结合使用CSS和jQuery来完成您需要的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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