jquery real-battle imitation flash button effect

Source: Internet
Author: User
Tags relative

The following small example, inspired by the Youa application (now seems to be gone), is when the mouse is moved up and removed, the icon will have the effect of easing. The effect is no worse than Flash.

51CTO recommendation: jquery from getting started to mastering the jquery Power plugin Grand Parade

The following is the effect of the picture: The icon is very good design, here will not teach you how to design.

The following is the code section for JQ:

 
 
  1. $ (function () {
  2. Append img to LI
  3. $ ("#nav-shadow li"). Append ("
  4. Width= "height=" "alt=" "/>");//This is a picture of the shadow
  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 () {//callback function control
  10. $ ($e). Find ("a"). Animate ({margintop: " -10px"},250);
  11. });
  12. $ ($e). Find ("Img.shadow"). Stop (). Animate ({width: "80%", Opacity: "0.3", MarginLeft: "8px"},250);
  13. },function () {
  14. var $e = this;
  15. $ ($e). Find ("a"). Stop (). Animate ({margintop: "4px"},250,function () {
  16. $ ($e). Find ("a"). Animate ({margintop: "0px"},250);
  17. });
  18. $ ($e). Find ("Img.shadow"). Stop (). Animate ({width: "100%", Opacity: "1", MarginLeft: "0px"},250);
  19. }
  20. )
  21. })

Analysis:

First increase the reflection:

 
  
  
  1. $ ("#nav-shadow li"). Append ("
  2. Width= "height=" "alt=" "/>"

Then register, hover the event, and use the callback function to control the bounce back effect. The sense of distance in the shadow is controlled by transparency.

Here is the HTML code:

 
 
  1. <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >
  2. <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
  3. <title>button_effect</title>
  4. <script type= "Text/javascript" src= "Jquery-1.4.2.min.js" ></script>
  5. <script type= "Text/javascript" src= "Action.js" ></script>
  6. <style type= "Text/css" >
  7. *{margin:0; padding:0;}
  8. div{width:500px; height:500px margin:100px 0 auto;
  9. ul,ol{list-style:none; list-style-type:none;}
  10. a,a:visited,a:hover{display:block; text-decoration:none; color: #ccc; text-indent:-9999px;
  11. outline:0 none; width:61px; height:60px; Z-index:2;  Overflow:hidden; Position:relative;}
  12. li{float:left; width:61px; height:92px; margin-left:10px; position:relative;
  13. #nav-shadow li.chang-one a{background:url (images/button_pic.jpg) no-repeat left top;}
  14. #nav-shadow li.chang-two a{background:url (images/button_pic.jpg) no-repeat-60px top;
  15. #nav-shadow li.chang-three a{background:url (images/button_pic.jpg) no-repeat-120px top;
  16. #nav-shadow li.chang-four a{background:url (images/button_pic.jpg) no-repeat-180px top;
  17. #nav-shadow li.chang-five a{background:url (images/button_pic.jpg) no-repeat-240px top;
  18. #nav-shadow li img.shadow{margin:0 Auto; position:absolute; bottom:0px; left:0px; z-index:1;}
  19. </style>
  20. <body>
  21. <div id= "Content" >
  22. <ul id= "Nav-shadow" >
  23. <li class= "Chang-one" ><a href= "#" title= "Reflaction_one" >click me</a></li>
  24. <li class= "Chang-two" ><a href= "#" title= "Reflaction_two" >click me</a></li>
  25. <li class= "Chang-three" ><a href= "#" title= "Reflaction_three" >click me</a></li>
  26. <li class= "Chang-four" ><a href= "#" title= "Reflaction_four" >click me</a></li>
  27. <li class= "chang-five" ><a href= "#" title= "reflaction_five" >click me</a></li>
  28. </ul>
  29. </div>
  30. </body>

When you are using it, you just need to design a nice icon.

New Source Download: Download

Original link: http://www.cnblogs.com/blacksheep/archive/2011/04/13/2014416.html

"Edit Recommendation"

    1. Share 24 very useful jquery Plug-ins
    2. jquery Drag layout implement sort results Sync database
    3. To teach you to use jquery to do animation plug-ins
    4. Cool jquery validation plug-ins in asp.net mvc
    5. 30 Latest awesome jquery light box plugin
"Responsible editor: Chen Yu new TEL: (010) 68476606"


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.