基于jQuery实现的向下滑动二级菜单效果代码
本文实例讲述了基于jQuery实现的向下滑动二级菜单效果代码。分享给大家供大家参考。具体如下:
这是一款使用jQuery制作向下滑动的二级菜单,本二级菜单带有动画效果,而且比较流畅,鼠标放在一级菜单上,就可以向下滑出二级子菜单,相对实用。
运行效果截图如下:
在线演示地址如下:
http://demo.jb51.net/js/2015/jquery-show-down-style-menu-codes/
具体代码如下:
<!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(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(images/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="jquery-1.6.2.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="蛋白粉">乳清蛋白粉</a></li> <li><a href="#" title="热门标签">增肌粉</a></li> </ul> </div> </li> <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> </ul> </div> <div class="clear"></div> </div> </body> </html>
希望本文所述对大家的jquery程序设计有所帮助。
赞 (0)