jQuery流畅动态导航菜单特效代码

版权:原创 更新时间:1年以上
[该文章底部包含文件资源,可根据自己情况,决定是否下载资源使用,时间>金钱,如有需要,立即查看资源]

以下是 jQuery流畅动态导航菜单特效代码 的示例演示效果:

当前平台(PC电脑)
  • 平台:

部分效果截图:

jQuery流畅动态导航菜单特效代码

HTML代码(index.html):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="imagetoolbar" content="no" />
	<title>流畅的动态jQuery导航</title>
	<link rel="stylesheet" href="style.css" />
	<style>
		
		/**	style used for both examples **/

		.menu { 
			height: 45px;
			display: block;
		}

		.menu ul {
			list-style: none;
			padding: 0;
			margin: 0;
		}

		.menu ul li {
			/* width and height of the menu items */  
			float: left;
			overflow: hidden;
			position: relative;
			text-align: center;
			line-height: 45px;
		}

		.menu ul li a {
			/* must be postioned relative  */ 
			position: relative;
			display: block;
			width: 110px;
			height: 45px;
			font-family: Arial;
			font-size: 11px;
			font-weight: bold;
			letter-spacing: 1px;
			text-transform: uppercase;
			text-decoration: none;
			cursor: pointer;
		}

		.menu ul li a span {
			/* all layers will be absolute positioned */
			position: absolute;
			left: 0;
			width: 110px;
		}

		.menu ul li a span.out {
			top: 0px;
		}

		.menu ul li a span.over,
		.menu ul li a span.bg {
			/* hide */  
			top: -45px;
		}

		/** 1st example **/

		#menu {
			background: #EEE;
		}

		#menu ul li a {
			color: #000;
		}

		#menu ul li a span.over {
			color: #FFF;
		}

		#menu ul li span.bg {
			/* height of the menu items */  
			height: 45px;
			background: url('bg_over.gif') center center no-repeat;
		}
		
		/** 2nd example **/

		#menu2 {
			background: #000;		
		}
		
		#menu2 ul li a {
			color: #FFF;
		}

		#menu2 ul li a span.over {
			background: #FFF;
			color: #000;
		}

	</style>
	<script type="text/javascript" src="jquery.min.js"></script>
	<script language="javascript">
		$(document).ready(function() {

			/* 	1st example	*/

			/// wrap inner content of each anchor with first layer and append background layer
			$("#menu li a").wrapInner( '<span class="out"></span>' ).append( '<span class="bg"></span>' );

			// loop each anchor and add copy of text content
			$("#menu li a").each(function() {
				$( '<span class="over">' +  $(this).text() + '</span>' ).appendTo( this );
			});

			$("#menu li a").hover(function() {
				// this function is fired when the mouse is moved over
				$(".out",	this).stop().animate({'top':	'45px'},	250); // move down - hide
				$(".over",	this).stop().animate({'top':	'0px'},		250); // move down - show
				$(".bg",	this).stop().animate({'top':	'0px'},		120); // move down - show

			}, function() {
				// this function is fired when the mouse is moved off
				$(".out",	this).stop().animate({'top':	'0px'},		250); // move up - show
				$(".over",	this).stop().animate({'top':	'-45px'},	250); // move up - hide
				$(".bg",	this).stop().animate({'top':	'-45px'},	120); // move up - hide
			});
					

			/*	2nd example	*/
			
			$("#menu2 li a").wrapInner( '<span class="out"></span>' );
			
			$("#menu2 li a").each(function() {
				$( '<span class="over">' +  $(this).text() + '</span>' ).appendTo( this );
			});

			$("#menu2 li a").hover(function() {
				$(".out",	this).stop().animate({'top':	'45px'},	200); // move down - hide
				$(".over",	this).stop().animate({'top':	'0px'},		200); // move down - show

			}, function() {
				$(".out",	this).stop().animate({'top':	'0px'},		200); // move up - show
				$(".over",	this).stop().animate({'top':	'-45px'},	200); // move up - hide
			});

		});

	</script>
</head>
<body>
	<div id="content">
		<h1>流畅的动态jQuery导航</h1>
		
		<hr />
		
		<p>Complete example</p>
		
		<div id="menu" class="menu">
			<ul>
				<li><a href="javascript:;">Home</a></li>
				<li><a href="javascript:;">Work</a></li>
				<li><a href="javascript:;">Services</a></li>
				<li><a href="javascript:;">Support</a></li>
				<li><a href="javascript:;">Contacts</a></li>
			</ul>
		</div>
		
		<p>&nbsp;</p>
		
		<p>Simple</p>
		
		<div id="menu2" class="menu">
			<ul>
				<li><a href="javascript:;">Home</a></li>
				<li><a href="javascript:;">Work</a></li>
				<li><a href="javascript:;">Services</a></li>
				<li><a href="javascript:;">Support</a></li>
				<li><a href="javascript:;">Contacts</a></li>
			</ul>
		</div>
	</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-4230547-2");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>







CSS代码(style.css):

body{background:#EEE;font-family:"Trebuchet MS",Verdana,Arial,sans-serif;font-size:14px;line-height:1.6;}
#content{width:750px;margin:50px auto;padding:20px;background:#FFF;border:1px solid #CCC;}
h1{margin:0;}
hr{border:none;height:1px;line-height:1px;background:#CCC;margin-bottom:20px;padding:0;}
p{margin:0;padding:7px 0;}
附件:下载该文件资源,减少时间成本(增值服务)
留言
该资源可下载
File Source
.rar
154.05 KB
Html Js 菜单导航特效3
最新结算
jquery虚拟键盘中文打字效果js代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
jquery虚拟键盘中文打字效果js代码
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
HTML5实现CSS滤镜图片切换特效代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
jQuery头像裁剪插件cropbox js代码
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
jQuery头像裁剪插件cropbox js代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
jQuery+css3实现信封效果
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
我们力求给您提供有用的文章,再此基础上,会附加营收资源,不做任何广告,让平台可以更好发展 若您发现您的权利被侵害,或使用了您的版权,请发邮件联系 sunlifel@foxmail.com ggbig觉得 : 不提供源码的文章不是好文章
合作伙伴
联系我们
  • QQ:21499807
  • 邮箱:sunlifel@foxmail.com
  • QQ扫一扫加QQ
    QQ扫一扫
Copyright 2023-2024 ggbig.com·皖ICP备2023004211号-1
打赏文章