利用CSS3制作的一个带动画的Download按钮.不需要javascript的CSS3动画.同时使用了渐变背景色来增强质感.
IE9暂不支持CSS3动画和渐变背景,所以本效果在IE9下不能正常显示动画效果.
HTML
CSS
a {
text-decoration: none;
transition-property: all;/*CSS3动画属性*/
transition-duration: .5s;/*动画时间*/
-webkit-transition-property: all;
-webkit-transition-duration: .5s;
-moz-transition-property: all;
-moz-transition-duration: .5s;
}
.download_button, .download_button2 {
height: 20px;
width: 100px;
}
.button_icon {
float: left;
height: 20px;
width: 20px;
background-repeat: no-repeat;
background-position: center bottom;
text-decoration: none;
transition-property: all;/*需要左边的箭头有动画滑动效果,这里必须再次添加动画设定*/
transition-duration: .5s;
-webkit-transition-property: all;
-webkit-transition-duration: .5s;
-moz-transition-property: all;
-moz-transition-duration: .5s;
}
.button_text {
line-height: 20px;
float: left;
height: 20px;
width: 70px;
text-align: center;
}
Button A
CSS
.download_button a {
display: block;
float: left;
height: 20px;
width: 90px;
color: #333;
text-shadow: 0 1px 1px rgba(255,255,255,0.7);
border-radius: 10px;
box-shadow: 0 1px 3px rgba(0,0,0,0.5);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
overflow: hidden;
padding-right: 5px;
padding-left: 5px;
background: #f7f7f7;
/*这里开始往下为渐变背景色设定*/
background: -webkit-gradient(linear, 0 0, 0 100%, from(#f7f7f7), to(#eeeeee));
background: -moz-linear-gradient(top, #f7f7f7, #eeeeee);
}
.download_button a:hover {
color: #1768ca;
}
.download_button .button_icon {
background-image: url(../images/button_1.png);
}
.download_button a:hover .button_icon {
background-position: center top;
}
Button B
CSS
.download_button a {
display: block;
float: left;
height: 20px;
width: 90px;
color: #fff;
text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
border-radius: 10px;
box-shadow: 0 1px 3px rgba(0,0,0,0.5);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
-moz-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
overflow: hidden;
padding-right: 5px;
padding-left: 5px;
background: #4fa5e6;
/*这里开始往下为渐变背景色设定*/
background: -webkit-gradient(linear, 0 0, 0 100%, from(#4fa5e6), to(#377ad0));
background: -moz-linear-gradient(top, #4fa5e6, #377ad0);
}
.download_button a:hover {
background: #4fa5e6;
background: -webkit-gradient(linear, 0 0, 0 100%, from(#3b9be3), to(#1768ca));
background: -moz-linear-gradient(top, #3b9be3, #1768ca);
}
.download_button .button_icon {
background-image: url(../images/button_2.png);
}
.download_button2 a:hover .button_icon {
background-position: center top;
}