
这个教程主要讲解如何jquery制作仿Skype的动画按钮。
![]()
制作过程
创建如下按钮链接:
- <a class="button" href="#">
- <img src="button.png" alt="" />Send info
- </a>
- or <a href="#">cancel</a>
给这个按钮链接,添加样式
- .button {
- padding: 4px 10px 3px 25px;
- border: solid 1px #8AB134;
- position: relative;
- cursor: pointer;
- display: inline-block;
- background-image: url( 'bkg.png' );
- background-repeat: repeat-x;
- font-size: 11px;
- height: 16px;
- text-decoration: none;
- color: #40740D;
- -moz-border-radius-bottomleft: 5px;
- -moz-border-radius-bottomright: 5px;
- -moz-border-radius-topleft: 5px;
- -moz-border-radius-topright: 5px;
- }
- .button img {
- position: absolute;
- top: -4px;
- left: -12px;
- border: none;
- }
- .button:hover {
- color: #8AB134;
- }
这里用到了css3的圆角属性,在IE下无法正常显示圆角,而且使用的是png,IE6下需要自行修正。
按钮链接内的修饰图标使用绝对定位。
动画关键脚本:
- $(".button").hover(function(){
- $(".button img")
- .animate({top:"-10px"}, 200).animate({top:"-4px"}, 200)
- .animate({top:"-7px"}, 100).animate({top:"-4px"}, 100)
- .animate({top:"-6px"}, 100).animate({top:"-4px"}, 100);
- });
改变钮链接内的修饰图标的top值,形成上下跳动的动画形式。

这个特效不错 收藏了