<!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"> * { margin: 0; padding: 0; font-size: 14px; } a { color: #333; text-decoration: none } ul{ list-style: none; } .nav {height: 30px; border-bottom: 5px solid #F60; margin-left:50px; width:600px;} .nav li { float: left; position:relative; height:30px; width:120px } .nav li a { display: block; height: 30px; text-align: center; line-height: 30px; width:120px; background: #efefef; margin-left: 1px; } .subNav{ position:absolute; top:30px; left:0; width:120px; height:120px; overflow:hidden;display: none;} .subNav li a{ background:#ddd } .subNav li a:hover{ background:#efefef} </style> <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script> <script> $(function(){ var LI=$("li"); LI.mouseenter(function(){ $(this).find(".subNav").slideDown(); }) LI.mouseleave(function(){ $(this).find(".subNav").slideUp(); }) }) </script> </head> <body> <ul class="nav"> <li><a href="#">一级菜单</a> <ul class="subNav"> <li><a href="#">二级菜单</a></li> <li><a href="#">二级菜单</a></li> <li><a href="#">二级菜单</a></li> <li><a href="#">二级菜单</a></li> </ul> </li> <li><a href="#">一级菜单</a> <ul class="subNav"> <li><a href="#">二级菜单</a></li> <li><a href="#">二级菜单</a></li> <li><a href="#">二级菜单</a></li> <li><a href="#">二级菜单</a></li> </ul> </li> <li><a href="#">一级菜单</a></li> <li><a href="#">一级菜单</a></li> <li><a href="#">一级菜单</a></li> </ul> <div id="content"> 123 </div> </body> </html>
stone310