自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

jQuery實戰(zhàn)之仿Flash跳動的按鈕效果

開發(fā) 前端
運用jQuery在配合漂亮的UI,就可以做出讓用戶賞心悅目的體驗。

下面這個小例子,靈感來源于百度有啊的應用(現(xiàn)在好像沒有了),就是當鼠標移上去和移除,圖標會有緩動的效果。效果不比flash的差。

51CTO推薦專題:jQuery從入門到精通  jQuery給力插件大閱兵

下面是的效果圖:圖標很好設計,在這里就不教大家怎么設計了。

jQuery實戰(zhàn)之仿Flash跳動的按鈕效果

下面是JQ的代碼部分:

  1. $(function(){   
  2.       //append img to LI   
  3.       $("#nav-shadow li").append('<img class="shadow" src="images/reflaction_pic.jpg" 
  4. width="60" height="32"  alt="" />');//這是陰影的圖片   
  5.       //append hover event   
  6.       $("#nav-shadow li").hover(function(){   
  7.      //define e for tihs   
  8.           var $e = this;   
  9.          $($e).find("a").stop().animate({marginTop:'-14px'},250,function(){//回調(diào)函數(shù)控制   
  10.               $($e).find("a").animate({marginTop:'-10px'},250);  
  11.               
  12.          });  
  13.          $($e).find("img.shadow").stop().animate({width:"80%",opacity:"0.3",marginLeft:"8px"},250);                  
  14.            
  15.      },function(){  
  16.          var $e = this;  
  17.          $($e).find("a").stop().animate({marginTop:"4px"},250,function(){  
  18.              $($e).find("a").animate({marginTop:"0px"},250);  
  19.          });      
  20.          $($e).find("img.shadow").stop().animate({width:"100%",opacity:"1",marginLeft:"0px"},250);              
  21.         }  
  22.         )  
  23.      }) 

分析:

首先增加倒影:

  1. $("#nav-shadow li").append('<img class="shadow" src="images/reflaction_pic.jpg" 
  2. width="60" height="32"  alt="" />'

然后注冊,hover事件,用回調(diào)函數(shù)控制彈回去時候的效果。陰影的距離感是通過透明度控制的。

下面是HTML代碼:

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">   
  2.   <html>   
  3.      <head>   
  4.          <meta http-equiv="Content-Type" content="text/html; charset=utf-8">   
  5.          <title>button_effect</title>   
  6.          <script type="text/javascript" src="jquery-1.4.2.min.js"></script>   
  7.          <script type="text/javascript" src="action.js"></script>   
  8.          <style type="text/css">   
  9.              *{ margin:0; padding:0;}  
  10.              div{ width:500px; height:500px; margin:100px 0 auto;}  
  11.              ul,ol{ list-style:none; list-style-type:none;}  
  12.              a,a:visited,a:hover{ display:block; text-decoration:none; color:#ccc; text-indent:-9999px; 
  13. outline: 0 none; width:61px; height:60px; z-index:2; overflow:hidden;  position:relative;}  
  14.              li{ float:left; width:61px; height:92px; margin-left:10px; position:relative;}      
  15.              #nav-shadow li.chang-one a{ background:url(images/button_pic.jpg) no-repeat left top;}  
  16.              #nav-shadow li.chang-two a{background:url(images/button_pic.jpg) no-repeat -60px top;}  
  17.              #nav-shadow li.chang-three a{background:url(images/button_pic.jpg) no-repeat -120px top;}  
  18.              #nav-shadow li.chang-four a{background:url(images/button_pic.jpg) no-repeat -180px top;}  
  19.              #nav-shadow li.chang-five a{background:url(images/button_pic.jpg) no-repeat -240px top;}  
  20.              #nav-shadow li img.shadow{margin:0 auto; position:absolute; bottom:0px; left:0px; z-index:1;}  
  21.          </style>  
  22.      </head>  
  23.      <body>  
  24.       <div id="content">  
  25.           <ul id="nav-shadow">  
  26.               <li class="chang-one"><a href="#" title="reflaction_one">click me</a></li>  
  27.              <li class="chang-two"><a href="#" title="reflaction_two">click me</a></li>  
  28.              <li class="chang-three"><a href="#" title="reflaction_three">click me</a></li>  
  29.              <li class="chang-four"><a href="#" title="reflaction_four">click me</a></li>  
  30.              <li class="chang-five"><a href="#" title="reflaction_five">click me</a></li>          
  31.           </ul>  
  32.       </div>  
  33.      </body>  
  34.  </html> 

大家在用的時候,只需要設計出好看的圖標就可以了。

新加了源碼下載:下載

原文鏈接:http://www.cnblogs.com/blacksheep/archive/2011/04/13/2014416.html

【編輯推薦】

  1. 分享24款非常有用的jQuery插件
  2. jQuery拖動布局實現(xiàn)排序結果同步數(shù)據(jù)庫
  3. 手把手教你用jQuery做動畫插件
  4. ASP.NET MVC中很酷的jQuery驗證插件
  5. 30個最新超棒的jQuery燈箱插件
責任編輯:陳貽新 來源: 博客園
相關推薦

2010-09-02 09:26:04

FlashAndroid

2011-03-30 14:33:57

jQueryJavaScript

2011-06-03 09:34:14

Android iphone tab

2011-06-03 09:05:18

Android iphone tab

2011-05-04 09:05:39

Flash

2015-07-21 15:22:20

點贊仿知乎按鈕動畫

2015-03-30 14:24:06

網(wǎng)易布局

2012-06-19 13:45:57

Web

2015-02-02 16:42:49

特效密碼鎖

2012-05-29 10:36:43

jQuery

2015-07-17 10:41:59

點贊按鈕

2015-07-23 15:15:06

動態(tài)彈出

2015-01-19 12:19:04

iOS源碼ActionSheet仿QQ音樂

2023-01-03 16:54:27

字節(jié)跳動深度學習

2015-03-31 18:19:37

餓了么動畫效果

2016-08-30 21:36:56

JavascriptCSSWeb

2012-04-26 10:56:05

jQuery效果

2017-03-22 10:35:06

AndroidRecyclerVie滑動效果

2011-07-21 16:10:11

button按鈕jQuery Mobi

2021-12-07 11:30:32

Go煮蛋計時器
點贊
收藏

51CTO技術棧公眾號