jQuery方式实现动画菜单

    xiaoxiao2025-03-30  14

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="js/jquery-3.4.1.min.js"></script> <title>三级菜单</title> <script> $(function () { $(".top-nav li").mousemove(function () { $(this).children("ul").slideDown("1000"); }) $(".top-nav li").mouseleave(function () { $(this).children("ul").slideUp("slow"); }) }); </script> <style> a { color: #FFFF99; text-decoration: none; } .top-nav { font-size: 16px; font-weight: bold; /* 去小圆点 */ list-style: none; } .top-nav li { float: left; /* 每个菜单之间有1像素间距 */ margin-right: 1px; } /* 二级菜单 */ .top-nav li ul { display: none; /* 去圆点 */ list-style: none; padding: 0px; position: absolute; float: left; } .top-nav li a { line-height: 34px; text-decoration: none; background: #DDDDDD; color: #666666; display: block; width: 80px; text-align: center; } .top-nav li a:hover { background: url("images/slide-bg.PNG") repeat-x; } .top-nav li:hover ul { display: block; } .note { display: block; color: #3f240e; background: url("images/slide-bg.PNG") repeat-x; } .corner { display: block; height: 18px; background: url("images/corner.PNG") 27px 0 no-repeat; } </style> </head> <body> <div id="top"> <ul class="top-nav"> <li><a href="#"><span class="note">首页</span></a></li> <li><a href="#">课程大厅</a></li> <li><a href="#">学习中心</a> <ul> <span class="corner"></span> <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> </ul> </div> </body> </html>

     

    最新回复(0)