以下是 jQuery动画二级下拉菜单代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery动画二级下拉菜单代码</title>
<style>
*{ margin:0; padding:0; list-style:none;}
img{ border:0;}
body{ padding-top:100px;}
#zzsc{ width:100%; height:200px; overflow:hidden; position:relative;}
#zzsc ul{ width:800px;overflow:hidden;height:auto; position:absolute; left:50%; top:0; margin-left:-400px; z-index:30;}
#zzsc ul li{ width:100px; height:auto; overflow:hidden;float:left; text-align:center; position:relative;}
#zzsc ul li a{ width:100%; height:40px; line-height:40px; margin-bottom:10px;display:block; float:left;font-size:14px; font-family:'微软雅黑'; color:#666; font-weight:bold; text-decoration:none;background:url(img/nav_line.jpg) left center no-repeat;}
#zzsc ul li a.first{ background:none;}
#zzsc ul li a:hover{text-decoration:none;}
#zzsc ul li.on a{ color:#e46b12;}
#zzsc ul li .second{ width:80px; height:130px; padding:10px; float:left; background:#ccc; display:none;}
#zzsc .dot{ width:800px;height:8px; line-height:8px; position:absolute; left:50%; top:40px; margin-left:-400px; z-index:20;}
#zzsc .dot ul{width:800px;height:8px; line-height:8px; position:relative;}
#zzsc .dot ul span{ width:100px; height:8px; background:url(img/dot.gif) no-repeat center center; display:block; position:absolute; left:0; top:0;}
#zzsc #slide{ width:100%; height:0; background:#e46b12; overflow:hidden; position:absolute; left:0; top:50px; z-index:10;}
</style>
</head>
<body>
<div id="zzsc">
<ul id="nav">
<li class="on"><a href="http://www.baidu.com/?flash" class="first">Flash素材</a><div class="second">1</div></li>
<li><a href="http://www.baidu.com/?nav">菜单导航</a><div class="second">2</div></li>
<li><a href="http://www.baidu.com/?time">时间日期</a><div class="second">3</div></li>
<li><a href="http://www.baidu.com/?banner">焦点图</a><div class="second">4</div></li>
<li><a href="http://www.baidu.com/?tab">tab标签</a><div class="second">5</div></li>
<li><a href="http://www.baidu.com/?jquery">jquery特效</a><div class="second">6</div></li>
<li><a href="http://www.baidu.com/?service">在线客服</a><div class="second">7</div></li>
<li><a href="http://www.baidu.com/?pic">图片特效</a><div class="second">8</div></li>
</ul>
<div class="dot"><ul><span></span></ul></div>
<div id="slide"></div>
</div>
<script src="js/jquery.min.js"></script>
<script>
$(function(){
var liWidth = $('#zzsc #nav li').width();
var secondWidth = $('#zzsc #nav2 .second').width();
$('#zzsc #nav li').hover(function(){
var index = $(this).index();
$('#zzsc .dot span').stop().animate({
left:liWidth*index+'px'
},200);
$(this).addClass('on').siblings().removeClass('on');
$(this).find('.second').fadeIn(600);
$('#zzsc #slide').stop().animate({
height:'150px'
},400);
},function(){
$(this).find('.second').fadeOut(600);
$('#zzsc #slide').stop().animate({
height:'0'
},400);
});
});
</script>
</body>
</html>