jQuery实现导航回弹效果
效果图:
代码如下:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script src="http://www.21kevin.com/js/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script> <script src="http://www.21kevin.com/js/move.js" type="text/javascript" charset="utf-8"></script> <style type="text/css"> *{margin:0;padding:0;} .box{width:1100px ;height: 70px;margin: 100px auto;background: hotpink;padding: 0 0 0 200px;box-sizing: border-box;} .nav {float: left;height: 70px;line-height: 55px;position: relative;cursor: pointer;} .nav-now{background: url(images/nav_now_bg.png)center 50px no-repeat;} .nav h1{font-size: 24px;} .box .nav+.nav{margin-left: 50px;} .box .nav span{width: 25px;height: 25px;position: absolute;background: url(images/nav_xiajiantou.png)center no-repeat;top: 15px;right: -35px;} .nav ul{position: absolute;background: hotpink;width: 160px;top: 70px;left: -15px;display: none;} .nav ul li{list-style: none;line-height: normal;padding: 10px 0 10px 20px;cursor: pointer;transition:padding-left 0.5s ease; } .nav ul li:hover{background: yellowgreen url(images/nav_li_bg.png)142px center no-repeat;padding-left:35px ;} .nav:hover{background: url(images/nav_now_bg.png)center 50px no-repeat;} </style> </head> <body> <div class="box"> <div class="nav has-nav nav-now"> <h1>一级菜单</h1> <span></span> <ul> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> </ul> </div> <div class="nav has-nav"> <h1>一级菜单</h1> <span></span> <ul> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> </ul> </div> <div class="nav has-nav"> <h1>一级菜单</h1> <span></span> <ul> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> <li>二级菜单</li> </ul> </div> <div class="nav"> <h1>一级菜单</h1> </div> </div> </body> <script> $(function(){ $(".has-nav").hover(function(){ $(this).find('ul').slideDown(600,"elasticOut"); },function(){ $(this).find('ul').stop().slideUp(100); }); $(".nav").click(function(){ $(this).addClass("nav-now").siblings().removeClass("nav-now") }) }) </script> </html>
相关推荐
89510194 2020-06-27
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18