jquery上下翻滚效果导航菜单(仿flash)

<!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上下翻滚效果导航菜单(仿flash)</title>
    <meta name="keywords"  />
<meta name="description"  />

<style>




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;
}






.menu { 
height: 45px;
display: block;
}
.menu ul {
list-style: none;
padding: 0;
margin: 0;
}
.menu ul li {
float: left;
overflow: hidden;
position: relative;
text-align: center;
line-height: 45px;
}
.menu ul li a {
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 {
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 {
top: -45px;
}
#menu {
background: #EEE;
}
#menu ul li a {
color: #000;
}
#menu ul li a span.over {
color: #FFF;
}


#menu ul li span.bg {
height: 45px;
background: url('bg_over.gif') center center no-repeat;
}
#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上下翻滚效果导航菜单(仿flash)</h1>
<hr />
<div id="menu" class="menu">
<ul>
<li><a href="http://51xuediannao.com">懒人建站</a></li>
<li><a href="http://51xuediannao.com/JS">JS代码</a></li>
<li><a href="http://51xuediannao.com/JS/AD">广告代码</a></li>
<li><a href="http://51xuediannao.com/JS/texiao">网页特效</a></li>
<li><a href="http://51xuediannao.com/MOSS-WSS/">MOSS界面定制</a></li>
</ul>
</div>
<hr />
<div id="menu2" class="menu">
<ul>
<li><a href="http://51xuediannao.com">懒人建站</a></li>
<li><a href="http://51xuediannao.com/JS">JS代码</a></li>
<li><a href="http://51xuediannao.com/JS/AD">广告代码</a></li>
<li><a href="http://51xuediannao.com/JS/texiao">网页特效</a></li>
<li><a href="http://51xuediannao.com/MOSS-WSS/">MOSS界面定制</a></li>
<li><a href="http://51xuediannao.com/MOSS-WSS/">任意添加</a></li>
</ul>
</div>
</div>




</div>
</body>

</html>




注意包含Jquery包,jquery包可在网上下载



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值