手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

jQuery+CSS实现的菜单效果

[日期:2012-07-07] 来源:Linux社区  作者:xudepeng [字体:大 中 小]

2.     设置菜单的CSS样式

  1. body  
  2. {  
  3.     font-family:@微软雅黑;  
  4.     background:#f3f3f3;  
  5.     }  
  6. ul  
  7. {  
  8.     margin:0;  
  9.     padding:0;  
  10.     }  
  11. li  
  12. {  
  13.     width:100px;  
  14.     height:50px;  
  15.     float:left;  
  16.     color:#191919;  
  17.     text-align:center;  
  18.     overflow:hidden;  
  19.     }  
  20. a  
  21. {  
  22.     color:#fff;  
  23.     text-decoration:none;  
  24.     }  
  25. p  
  26. {  
  27.     padding:0px 5px;  
  28.     }  
  29. .subtext  
  30. {  
  31.     padding-top:15px;  
  32.     }  
  33.      
  34. .green{background:#6aa63b url('images/green-item-bg.jpg')top left no-repeat;}  
  35. .yellow{background:#FBC700 url('images/yellow-item-bg.jpg')top left no-repeat;}  
  36. .red{background:#D52100 url('images/red-item-bg.jpg')top left no-repeat;}  
  37. .purple{background:#5122B4 url('images/purple-item-bg.jpg')top left no-repeat;}  
  38. .blue{background:#0292C0 url('images/blue-item-bg.jpg')top left no-repeat;}  

3.   导入jquery-1.4.1.js和jquery动画效果扩展插件jquery.easing.js 1.3,并编写Jquery代码

  1. <link href="StyleSheet1.css" rel="stylesheet" type="text/css" />  
  2.     <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>  
  3.     <%--导入jquery动画效果扩展插件jquery.easing.js 1.3--%>  
  4.     <script src="jquery.easing.1.3.js" type="text/javascript"></script>  
  5.     <script type="text/javascript" >  
  6.         $(document).ready(function(){  
  7.          
  8.             //注册超链接的单击事件   
  9.             $("a").click(function(){  
  10.                 $(this).blur();      //失去焦点触发的事件   
  11.             });  
  12.              
  13.             //鼠标移到li上边的事件   
  14.             $("li").mouseover(function(){  
  15.                 //停在指定的元素上(stop)自定义动画(animate)   
  16.                 $(this).stop().animate({height: '200px' }, { queue: false, duration: 600, easing: 'easeOutBounce' })  
  17.             });  
  18.    
  19.             //鼠标移出li的事件   
  20.             $("li").mouseout(function(){  
  21.                 $(this).stop().animate({height:'50px'},{queue:false,duration:600,easing:'easeOutBounce'});  
  22.             });  
  23.    
  24.         });  
  25.    
  26.     </script>  

到此我们已经把效果做出来了,效果如下图所示:

linux
相关资讯       jQuery  jQuery教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款