导航栏置顶
来源:互联网 发布:飞秋2013正式版 mac版 编辑:程序博客网 时间:2024/06/10 07:41
1、实现顶部和侧边导航吸顶,侧边导航在footer接触导航底部时被上顶。
2、效果图
3、代码段
- 顶部导航
- 顶部导航
- 顶部导航
- 顶部导航
- 顶部导航
//导航吸顶 var forHeadHeight = $(".forHeadHeight").height(); var contentHeadHeight = $(".index-content .content-head").height(); var leftListHeight = $(".index-content .content-body .body-left").height(); var leftListWidth = $(".index-content .content-body .body-left").width(); var sWidth = $(window).width(); //屏幕变化时宽度取值改变 $(window).resize(function(){ sWidth = $(window).width(); leftListWidth = $(".index-content .content-body .body-left").width(); $(".index-content .content-body .left-list").css({"width":leftListWidth}); }); $.fn.smartFloatTop = function(offsetTop,topHeight,index,backgroundColor) { var position = function(element) { var top = element.offset().top-offsetTop, pos = element.css("position"); $(window).scroll(function() { var scrollTop = $(this).scrollTop(); if (scrollTop >= top) { element.css({ "position": "fixed", "top": topHeight+'px', "width":"100%", "z-index":index, "background-color":backgroundColor, }); }else { //取消吸顶 element.css({ "position": pos, "top":top, }); } }); }; return $(this).each(function() { position($(this)); });}; //导航吸顶,被底部撑上 $.fn.smartFloatNav = function(offsetTop,topHeight,index,backgroundColor) { var position = function(element) { var top = element.offset().top-offsetTop, pos = element.css("position"); $(window).scroll(function() { var scrollTop = $(this).scrollTop(); if (scrollTop >= top) { //吸顶 element.css({ "position": "fixed", "top": topHeight+'px', "width":leftListWidth, "z-index":index, "background-color":backgroundColor, "box-sizing":"content-box", "padding":"0 10px", "border-right":"1px solid #cfcfcf", "border-left":"1px solid #cfcfcf" }); var fTop = $(".foot-nav").offset().top; var fScrollTop = $(".foot-nav").scrollTop(); var wScrollTop = $(window).scrollTop(); var allHeight = forHeadHeight + contentHeadHeight+leftListHeight; var otherHeight = forHeadHeight + contentHeadHeight; var fOffset = wScrollTop+allHeight-fTop; if(sWidth>991){ if(fTop
- 左侧导航1
- 左侧导航1
- 左侧导航1
- 左侧导航1
- 左侧导航1
- 左侧导航1
- 左侧导航1
- 左侧导航1
阅读全文
0 0
- 导航栏置顶
- 监听导航滚动置顶
- [置顶]Java学习导航
- 在UWP中页面滑动导航栏置顶
- 根据页面滚动的距离确定导航栏是否置顶
- JS----导航置顶滑动效果
- 返回顶部 and 导航置顶
- ionic导航Android置顶问题
- [知了堂学习笔记]_css3特效第二篇--行走的线条&&置顶导航栏
- 导航跟随滚动条置顶移动
- 【博客管理】博客目录导航【置顶】
- 自定义ScrollView,实现导航条悬浮置顶
- 导航随着页面一直在置顶
- 导航栏滚动置顶(仿美团首页、且解决再fragment中无法使用OnWindowFocusChangeListener方法的问题)
- [置顶]Asp.Net大型项目实践系列导航
- 置顶菜单可用性研究,可使网站导航快22%
- 置顶菜单可用性研究,可使网站导航快22%
- 置顶菜单可用性研究,可使网站导航快22%
- 剑指offer:和为S的连续正数序列
- RTMP协议分析及推流过程
- 集成学习(ensemble learning)
- mysql的事务隔离级别
- 不同规则的中文分词对Lucene索引的影响
- 导航栏置顶
- 03测试计划中的元素
- vue-cli + webpack 多页面实例应用
- vim/vi指令
- python作业2
- OracleOCM认证
- Android——机制篇:Android中的接口回调机制
- 王爽.汇编.第三版.实验16.答案
- 深究AngularJS——自定义服务详解(factory、service、provider)