CSS3实现漂亮的按钮动画

Chrome下效果理想,Firefox,IE9下没有动画效果。

CSS代码片段

 

 

.button, .button:visited{
background:#222 url(overlay.png) repeat-x;
display:inline-block;
padding:5px 10px 6px;
color:#fff;
text-decoration:none;
/*border-radius*/
-webkit-border-radius:6px;
   -moz-border-radius:6px;
        border-radius:6px;
/*box-shadow*/
-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.6);
   -moz-box-shadow:0 1px 3px rgba(0,0,0,0.6);
        box-shadow:0 1px 3px rgba(0,0,0,0.6);
text-shadow:0 -1px 1px rgba(0,0,0,0.25);
border-bottom:1px solid rgba(0,0,0,0.25);
position:relative;
cursor:pointer;
}
.button:hover{
background-color:#111;
color:#fff;
/*animation-duration*/
-webkit-animation-duration:2s;
   -moz-animation-duration:2s;
    -ms-animation-duration:2s;
     -o-animation-duration:2s;
        animation-duration:2s;
/*animation-timing-function*/
-webkit-animation-timing-function:ease-out;
   -moz-animation-timing-function:ease-out;
    -ms-animation-timing-function:ease-out;
     -o-animation-timing-function:ease-out;
        animation-timing-function:ease-out;
/*animation-iteration-count*/
-webkit-animation-iteration-count:infinite;
   -moz-animation-iteration-count:infinite;
    -ms-animation-iteration-count:infinite;
     -o-animation-iteration-count:infinite;
        animation-iteration-count:infinite;
}
/*定义动画*/
@-webkit-keyframes greenPulse{
from { background-color:#91bd09;
/*box-shadow*/
-webkit-box-shadow:0 0 9px #333;
   -moz-box-shadow:0 0 9px #333;
        box-shadow:0 0 9px #333;
}
50%{
background-color:#B4E02C;
/*box-shadow*/
-webkit-box-shadow:0 0 18px #91bd09;
   -moz-box-shadow:0 0 18px #91bd09;
        box-shadow:0 0 18px #91bd09;
}
to{
background-color:#91bd09;
/*box-shadow*/
-webkit-box-shadow:0 0 9px #333;
   -moz-box-shadow:0 0 9px #333;
        box-shadow:0 0 9px #333;
}
}

.green.button, .green.button:visited{
background-color:#91bd09;
}
.green.button:hover{
/*animation-name*/
-webkit-animation-name:greenPulse;
   -moz-animation-name:greenPulse;
    -ms-animation-name:greenPulse;
     -o-animation-name:greenPulse;
        animation-name:greenPulse;
}

 

HTML代码片段

 

 

<ul>
	<li>
		<a class="button magenta super" href="#">按钮</a>
		<a class="button green super" href="#">按钮</a>
		<a class="button red super" href="#">按钮</a>
		<a class="button orange super" href="#">按钮</a>
		<a class="button blue super" href="#">按钮</a>
		<a class="button yellow super" href="#">按钮</a>
	</li>
	<li>
		<input type="button" class="button magenta super" value="按钮" />
		<input type="button" class="button green super" value="按钮" />
		<input type="button" class="button red super" value="按钮" />
		<input type="button" class="button orange super" value="按钮" />
		<input type="button" class="button blue super" value="按钮" />
		<input type="button" class="button yellow super" value="按钮" />	
	</li>
</ul>
 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值