本文实例讲述了jQuery实现的粘性滚动导航栏效果。分享给大家供大家参考,具体如下:
粘性滚动是当导航在滚动过程中会占粘于浏览器上,达到方便网站页面浏览的效果,也是一种用户体验,下面我们看一下是怎么实现的:
jQuery的 smint插件,也是一个导航菜单固定插件。当页滚动时,导航菜单会固定在顶部;当点击菜单时,页面会平滑的滚动到对应的区域。
兼容性
由于 smint 使用了 position: fixed,所以它不兼容 IE6。适用浏览器:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗.
引入文件
<link href="css/demo.css" rel="external nofollow" rel="stylesheet" type="text/css"> <script src="js/jquery.min.js"></script> <script src="js/jquery.smint.js"></script>
HTML
<body onload="setTimeout(function() { window.scrollTo(0, 1) }, 100);"> <div class="wrap"> <div class="subMenu"> <div class="inner"> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" id="sTop" class="subNavBtn">Home</a> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" id="s1" class="subNavBtn">Section 1</a> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" id="s2" class="subNavBtn">Section 2</a> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" id="s3" class="subNavBtn">Section 3</a> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" id="s4" class="subNavBtn">Section 4</a> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" id="s5" class="subNavBtn end">Section 5</a> </div> </div> <div class="section sTop"> <div class="inner"></div><br class="clear"> </div> <div class="section s1"> <div class="inner"><h1>Section 1</h1></div> </div> <div class="section s2"> <div class="inner"><h1>Section 2</h1></div> </div> <div class="section s3"> <div class="inner"><h1>Section 3</h1></div> </div> <div class="section s4"> <div class="inner"><h1>Section 4</h1></div> </div> <div class="section s5"> <div class="inner"><h1>Section 5</h1></div> </div> </div> </body>
注意:菜单的外部容器(如上例的 subMenu)需要设置样式 position:absolute,并且每个菜单的 a 标签需要设置 id,id 的值与下面对应区域的 class 的值一致。
JavaScript
$(function() { $('.subMenu').smint({ scrollSpeed : 1000 }); });
附:完整实例代码点击此处本站下载。
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery切换特效与技巧总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery拖拽特效与技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结》
希望本文所述对大家jQuery程序设计有所帮助。
本文向大家介绍jQuery实现的下雪动画效果示例【附源码下载】,包括了jQuery实现的下雪动画效果示例【附源码下载】的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了jQuery实现的下雪动画效果。分享给大家供大家参考,具体如下: html部分: jquery.snow.js: 不需要css样式 主要用到:setInterval-setInterval() 方法可按照指定的周期(以毫秒计)
本文向大家介绍jQuery实现背景弹性滚动的导航效果,包括了jQuery实现背景弹性滚动的导航效果的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了jQuery实现背景弹性滚动的导航效果。分享给大家供大家参考,具体如下: PS:这里再为大家推荐几款代码格式化、美化工具,相信大家在以后的开发过程中会用得到: 在线JavaScript代码美化、格式化工具: http://tools.jb51.n
本文向大家介绍jQuery实现带滚动导航效果的全屏滚动相册实例,包括了jQuery实现带滚动导航效果的全屏滚动相册实例的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了jQuery实现带滚动导航效果的全屏滚动相册。分享给大家供大家参考。具体如下: 运行效果图如下: 主要代码如下: 希望本文所述对大家的jQuery程序设计有所帮助。
本文向大家介绍jQuery实现菜单栏导航效果,包括了jQuery实现菜单栏导航效果的使用技巧和注意事项,需要的朋友参考一下 本文实例为大家分享了jQuery实现菜单栏导航效果的具体代码,供大家参考,具体内容如下 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持呐喊教程。
本文向大家介绍jQuery实现下滑菜单导航效果代码,包括了jQuery实现下滑菜单导航效果代码的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了jQuery实现下滑菜单导航效果代码。分享给大家供大家参考。具体如下: 这里演示jquery向下滑的导航菜单代码,黄色风格下滑菜单,可作为网站的主导航菜单,二级菜单向下滑出,兼容性也是很不错的,本菜单来源自网络,丢失原作者署名信息,请原作者看到后与我
本文向大家介绍jQuery实现的导航下拉菜单效果示例,包括了jQuery实现的导航下拉菜单效果示例的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了jQuery实现的导航下拉菜单效果。分享给大家供大家参考,具体如下: 效果图: 更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery切换特效与技巧总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQu
本文向大家介绍jQuery实现带滚动线条导航效果的方法,包括了jQuery实现带滚动线条导航效果的方法的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了jQuery实现带滚动线条导航效果的方法。分享给大家供大家参考。具体分析如下: 最早见到这种导航是在魅族的官网,当时(去年)觉得挺不错的但自己不会JavaScript,因此那时“可望而不可及”。今日去手机QQ for Android官网,又发
本文向大家介绍jquery实现二级导航下拉菜单效果实例,包括了jquery实现二级导航下拉菜单效果实例的使用技巧和注意事项,需要的朋友参考一下 大家都知道jQuery是一个框架,它对JS进行了封装,使其更方便使用。前面两篇博文分别是用CSS样式和JS实现的,那么这篇就用jQuery来实现二级下拉式菜单。 使用JQuery实现需要用到的知识有: 1)使用$(function(){...})获取到想要