css3 写小鸟的核心原理是用到了css3 的自定义动画属性keyframes ,它很灵活,允许你创建更多不一样的动画效果。写法
@keyframes myName
{
0% {xxxx}
10% {xxxx}
20% {xxxx}
30% {xxxx}
}
小鸟的代码片段是这样的,通过调用不同的背景图片
@keyframes myFrist
{
0% {background:url(images/bird1.png);background-size: 100% 100%}
12.5% {background:url(images/bird2.png);background-size: 100% 100%}
25% {background:url(images/bird3.png);background-size: 100% 100%}
37.5% {background:url(images/bird4.png);background-size: 100% 100%}
50% {background:url(images/bird5.png);background-size: 100% 100%}
65.7% {background:url(images/bird6.png);background-size: 100% 100%}
75% {background:url(images/bird7.png);background-size: 100% 100%}
87.5% {background:url(images/bird8.png);background-size: 100% 100%}
100% {background:url(images/bird1.png);background-size: 100% 100%}
}
演示
http://developer.qietu.com/p/css3bird/
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/css3-style/c50478.shtml