请选择 进入手机版 | 继续访问电脑版

jQuery页面滚动左侧悬浮固定导航菜单代码

[复制链接]
查看1964 | 回复0 | 2021-3-11 11:27 | 显示全部楼层 |阅读模式

jQuery页面滚动左侧悬浮固定导航菜单代码

jQuery页面滚动左侧悬浮固定导航菜单代码


这是一款页面滚动下拉的时候左侧悬浮固定导航菜单代码,jQuery页面滚动固定层菜单网页特效下载。
  1. js代码

  2. <script type="text/javascript">
  3.         $(function(){
  4.                 //设置标杆
  5.                 var _line=parseInt($(window).height()/3);
  6.                 $(window).scroll(function(){
  7.                         //滚动730px,左侧导航固定定位
  8.                         if ($(window).scrollTop()>730) {
  9.                                 $('.fl_l').css({'position':'fixed','top':10})
  10.                         }else{
  11.                                 $('.fl_l').css({'position':'','top':''})
  12.                         };
  13.                         $('.fl_l li').eq(0).addClass('active');
  14.                         //滚动到标杆位置,左侧导航加active
  15.                         $('.fl_r li').each(function(){
  16.                                 var _target=parseInt($(this).offset().top-$(window).scrollTop()-_line);
  17.                                 var _i=$(this).index();
  18.                                 if (_target<=0) {
  19.                                         $('.fl_l li').removeClass('active');
  20.                                         $('.fl_l li').eq(_i).addClass('active');
  21.                                 }
  22.                                 //如果到达页面底部,给左侧导航最后一个加active
  23.                                 else if($(document).height()==$(window).scrollTop()+$(window).height()){
  24.                                         $('.fl_l li').removeClass('active');
  25.                                         $('.fl_l li').eq($('.fl_r li').length-1).addClass('active');
  26.                                 }
  27.                         });
  28.                 });
  29.                 $('.fl_l li').click(function(){
  30.                         $(this).addClass('active').siblings().removeClass('active');
  31.                         var _i=$(this).index();
  32.                          $('body, html').animate({scrollTop:$('.fl_r li').eq(_i).offset().top-_line},500);
  33.                 });
  34.         });
  35. </script>
复制代码
jQuery页面滚动左侧悬浮固定导航菜单代码.zip (35.04 KB, 下载次数: 585)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

UID
436
贡献
4
丢币
318
主题
163
回帖
1
注册时间
2021-2-21
最后登录
2023-3-12