使用jQuery制作向下滑动的二级菜单

使用jQuery制作向下滑动的二级菜单,引入了Google托管的jquery代码,因此若初次运行有错误,则可能是jquery没有被加载,可刷新页面重试。本二级菜单带有动画效果,而且比较流畅,鼠标放在一级菜单上,就可以向下滑出二级子菜单,相对实用。
<!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>向下滑动的二级菜单</title>
<style type="text/css">
body{ margin:0px; padding:0px; font-family: Arial, Helvetica, sans-serif; background-color:#dedede; color:#333333; position:relative;}
a{ text-decoration:none;}
h1,h2,h3,li,ul,dd,dt,dl,input{ margin:0px; padding:0px; list-style:none;}
.clear{ clear:both; width:0px; height:0px; line-height:0px; overflow:hidden; font-size:0px; display:block;}
img {border: none;}
.top{ width:890px; height:68px; margin:0px auto; padding:10px 0px 2px 0px; background-color:#FFFFFF;}
.logo{ width:269px; height:68px; padding:0px 8px 0px 3px;  float:left;}
.logo h1{ width:269px; height:68px; background-image:url(http://www.xker.com/images/logo.gif); background-repeat:no-repeat;}
.logo h1 a{ display:block; width:269px; height:68px; line-height:68px; font-size:14px; text-indent:-999px;}
.topad{ width:610px; height:68px; float:left;}
.dh{ width:890px; height:39px;margin:0px auto; background-image:url(/xkerfiles/allimg/1207/nvabg.gif); background-repeat:repeat-x;}
.nav{ width:785px; height:38px; padding:1px 0px 0px 15px; float:left;}
.nav li{ height:38px; line-height:38px; float:left; font-size:14px; padding:0px 20px; color:#FFFFFF; position:relative;}
.nav li a{ color:#FFFFFF;}
.nav li a:hover{ text-decoration:underline; font-size:16px;}
.nav li .ttg{ height:auto; background-color:#FFFFFF; FILTER: alpha(opacity=80); opacity: 0.8; -moz-opacity: 0.8; position:absolute; left:0px; top:37px; z-index:1; width:150px; padding:10px 0px; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; box-shadow:2px 2px 3px #666666; display:none;}
.nav li .ttg li{ width:120px; line-height:30px; font-size:16px; padding:0px 10px; font-family:"微软雅黑";}
.nav li .ttg li a{ color:#000;}
.sc{ width:90px; height:38px; line-height:38px; float:left; font-size:14px; color:#FFFFFF; text-align:center;}
.sc a{ color:#FFFFFF;}
.sc a:hover{ text-decoration:underline;}
.ad{ width:890px; height:auto; margin:10px auto;}
.ad img{ float: left; width:445px; overflow:hidden;}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $(".nav li").hover(function(){
        $(this).find(".ttg").slideToggle(500);
    });
});
</script>
</head>
<body>
<div class="top">
<div class="logo"><h1><a href="/" title="">网站标题文字</a></h1></div>
<div class="topad"></div>
<div class="clear"></div>
</div>

<div class="dh">
<div class="nav">
<ul>
<li><a href="/" title="首页">首页</a>
<div class="ttg">
<ul>
<li><a href="#" title="网络学院">网络学院</a></li>
<li><a href="#" title="新闻中心">新闻中心</a></li>
<li><a href="#" title="免费资源">免费资源</a></li>
</ul>
</div>
</li>
<li><a href="#" title="网络程教">网络教程</a>
<div class="ttg">
<ul>
<li><a href="#" title="网络学院">photoshop</a></li>
<li><a href="#" title="热门标签">flash</a></li>
</ul>
</div>
</li>

</ul>
</div>
<div class="clear"></div>
</div>
</body>
</html>

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Grow your business fast with

Suku