jquery动感漂浮导航菜单代码分享


Posted in Javascript onApril 15, 2020

这是一款基于jquery实现动感漂浮导航菜单的特效代码,菜单可以上下浮动,动感十足,为自己的网站增加了活力,是一款非常实用的导航菜单特效源码。

运行效果图:

jquery动感漂浮导航菜单代码分享

点击:下载源码

为大家分享的jquery动感漂浮导航菜单代码如下

<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title>jQuery Floating Menu</title>
 <script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
 <script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
 <script>
 
 $(document).ready(function () {

 //get the default top value
 var top_val = $('#menu li a').css('top');

 //animate the selected menu item
 $('#menu li.selected').children('a').stop().animate({top:0}, {easing: 'easeOutQuad', duration:500}); 

 $('#menu li').hover(
 function () {
 
 //animate the menu item with 0 top value
 $(this).children('a').stop().animate({top:0}, {easing: 'easeOutQuad', duration:500}); 
 },
 function () {

 //set the position to default
 $(this).children('a').stop().animate({top:top_val}, {easing: 'easeOutQuad', duration:500}); 

 //always keep the previously selected item in fixed position 
 $('#menu li.selected').children('a').stop().animate({top:0}, {easing: 'easeOutQuad', duration:500}); 
 } 
 );
 
 });
 
 </script>
 
 <style>
 

 #menu {
 list-style:none; 
 padding:0;
 margin:0 auto;;
 height:70px;
 width:600px;
 }
 
 #menu li {
 float:left;
 width:109px;
 height:inherit;
 position:relative;
 overflow:hidden;
 }

 #menu li a {
 position:absolute;
 top:20px;
 text-indent:-999em;
 background:url(menu.png) no-repeat 0 0;
 display:block; 
 width:109px; 
 height:inherit;

 /* fast png fix for ie6 */
 position:relative;
 behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none",
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')",
this.src = "transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''),
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')",
this.runtimeStyle.backgroundImage = "none")),this.pngSet=true));
 }
 
 </style>
 
</head>
<body>
<br/><br/><br/>

<ul id="menu">
 <li><a href="#">Item 1</a></li>
 <li><a href="#">Item 2</a></li>
 <li><a href="#">Item 3</a></li>
 <li><a href="#">Item 4</a></li>
 <li><a href="#">Item 5</a></li>
</ul>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title>jQuery Floating Menu</title>
 <script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
 <script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
 <script>
 
 $(document).ready(function () {

 //get the default top value
 var top_val = $('#menu li a').css('top');

 //animate the selected menu item
 $('#menu li.selected').children('a').stop().animate({top:0}, {easing: 'easeOutQuad', duration:500}); 

 $('#menu li').hover(
 function () {
 
 //animate the menu item with 0 top value
 $(this).children('a').stop().animate({top:0}, {easing: 'easeOutQuad', duration:500}); 
 },
 function () {

 //set the position to default
 $(this).children('a').stop().animate({top:top_val}, {easing: 'easeOutQuad', duration:500}); 

 //always keep the previously selected item in fixed position 
 $('#menu li.selected').children('a').stop().animate({top:0}, {easing: 'easeOutQuad', duration:500}); 
 } 
 );
 
 });
 
 </script>
 
 <style>
 

 #menu {
 list-style:none; 
 padding:0;
 margin:0 auto;;
 height:70px;
 width:600px;
 }
 
 #menu li {
 float:left;
 width:109px;
 height:inherit;
 position:relative;
 overflow:hidden;
 }

 #menu li a {
 position:absolute;
 top:20px;
 text-indent:-999em;
 background:url(menu.png) no-repeat 0 0;
 display:block; 
 width:109px; 
 height:inherit;

 /* fast png fix for ie6 */
 position:relative;
 behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none",
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')",
this.src = "transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''),
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')",
this.runtimeStyle.backgroundImage = "none")),this.pngSet=true));
 }
 
 </style>
 
</head>
<body>
<br/><br/><br/>

<ul id="menu">
 <li><a href="#">Item 1</a></li>
 <li><a href="#">Item 2</a></li>
 <li><a href="#">Item 3</a></li>
 <li><a href="#">Item 4</a></li>
 <li><a href="#">Item 5</a></li>
</ul>

如果大家还想深入学习,可以点击jQuery级联菜单特效汇总、Javascript级联菜单特效汇总进行学习。

以上就是为大家分享的jquery动感漂浮导航菜单代码,希望大家可以喜欢。

Javascript 相关文章推荐
JavaScript语句可以不以;结尾的烦恼
Mar 08 Javascript
javascript之锁定表格栏位
Jun 29 Javascript
javascript 点击整页变灰的效果(可做退出效果)。
Jan 09 Javascript
使用RequireJS优化JavaScript引用代码的方法
Jul 01 Javascript
小议JavaScript中Generator和Iterator的使用
Jul 29 Javascript
Jquery中request和request.form和request.querystring的区别
Nov 26 Javascript
IE8 内存泄露(内存一直增长 )的原因及解决办法
Apr 06 Javascript
探讨跨域请求资源的几种方式(总结)
Dec 02 Javascript
vue2.0在table中实现全选和反选的示例代码
Nov 04 Javascript
使用FileReader API创建Vue文件阅读器组件
Apr 03 Javascript
记一次用ts+vuecli4重构项目的实现
May 21 Javascript
用几道面试题来看JavaScript执行机制
Apr 30 Javascript
JavaScript判断表单中多选框checkbox选中个数的方法
Aug 17 #Javascript
jquery实现动静态条形统计图
Aug 17 #Javascript
JS实现的5级联动Select下拉选择框实例
Aug 17 #Javascript
jquery+css3实现网页背景花瓣随机飘落特效
Aug 17 #Javascript
js简单实现Select互换数据的方法
Aug 17 #Javascript
基于jQuery通过jQuery.form.js插件使用ajax提交form表单
Aug 17 #Javascript
js实现的全国省市二级联动下拉选择菜单完整实例
Aug 17 #Javascript
You might like
ThinkPHP实现ajax仿官网搜索功能实例
2014/12/02 PHP
在PHP中输出JS语句以及乱码问题的解决方案
2019/02/13 PHP
php实现JWT验证的实例教程
2020/11/26 PHP
Aster vs KG BO3 第二场2.18
2021/03/10 DOTA
JavaScript 替换Html标签实现代码
2009/10/14 Javascript
Firebug入门指南(Firefox浏览器)
2010/08/21 Javascript
基于jquery的9行js轻松实现tab控件示例
2013/10/12 Javascript
js 两个日期比较相差多少天的实例
2017/10/19 Javascript
vue组件生命周期详解
2017/11/07 Javascript
Angular实现的日程表功能【可添加及隐藏显示内容】
2017/12/27 Javascript
js验证身份证号码记录的方法
2019/04/26 Javascript
Vue+ElementUI使用vue-pdf实现预览功能
2019/11/26 Javascript
js前端对于大量数据的展示方式及处理方法
2020/12/02 Javascript
Python struct模块解析
2014/06/12 Python
在Python中使用__slots__方法的详细教程
2015/04/28 Python
深入解析Python中的WSGI接口
2015/05/11 Python
python 中split 和 strip的实例详解
2017/07/12 Python
python解析html提取数据,并生成word文档实例解析
2018/01/22 Python
http请求 request失败自动重新尝试代码示例
2018/01/25 Python
Python使用jsonpath-rw模块处理Json对象操作示例
2018/07/31 Python
Pycharm如何运行.py文件的方法步骤
2020/03/03 Python
Python tkinter之ComboBox(下拉框)的使用简介
2021/02/05 Python
Python 图片处理库exifread详解
2021/02/25 Python
Python实现简单的2048小游戏
2021/03/01 Python
CSS 3.0 结合video视频实现的创意开幕效果
2020/06/01 HTML / CSS
澳大利亚优质葡萄酒专家:Vintage Cellars
2019/01/08 全球购物
来自世界各地的饮料:Flavourly
2019/05/06 全球购物
入党自我评价范文
2014/02/02 职场文书
简单的大学生自我鉴定
2014/02/18 职场文书
中学生教师节演讲稿
2014/09/03 职场文书
新学期主题班会
2015/08/17 职场文书
Nginx服务器如何设置url链接
2021/03/31 Servers
PHP连接MSSQL数据库案例,PHPWAMP多个PHP版本连接SQL Server数据库
2021/04/16 PHP
Pandas实现DataFrame的简单运算、统计与排序
2022/03/31 Python
victoriaMetrics库布隆过滤器初始化及使用详解
2022/04/05 Golang
Java获取字符串编码格式实现思路
2022/09/23 Java/Android