animation-name

本文详细介绍了使用CSS3实现的一个有趣的动画案例——一只会动的眼睛。通过对关键帧动画的设置,实现了眼睛左右移动的效果,展示了如何利用CSS3的animation属性进行创意设计。

//HTML

1
2
3
4
< div  id = "beastainer" >
< img  alt = ""  src = "https://developer.cdn.mozilla.net/media/img/beast-404_LE.png"  id = "beast404le" >
< img  alt = ""  src = "https://developer.cdn.mozilla.net/media/img/beast-404_RE.png"  id = "beast404re" >
< img  alt = ""  src = "https://developer.cdn.mozilla.net/media/img/beast-404.png"  class = "beast 404" >

//CSS3 animation-name

#beastainer {

float: right;

padding: 20px 0 20px 20px;

position: relative;

}

#beast404re,#beast404le {

position: absolute;

-webkit-animation-delay: 6s;

-moz-animation-delay: 6s;

-ms-animation-delay: 6s;

animation-delay: 6s;

-webkit-animation-duration: 7s;

-moz-animation-duration: 7s;

-ms-animation-duration: 7s;

animation-duration: 7s;

-webkit-animation-iteration-count: infinite;

-moz-animation-iteration-count: infinite;

-ms-animation-iteration-count: infinite;

animation-iteration-count: infinite;

-webkit-animation-play-state: running;

-moz-animation-play-state: running;

-ms-animation-play-state: running;

animation-play-state: running

}

#beast404re {

left: 231px;

top: 68px;

-webkit-animation-name: crazyrighteye;

-moz-animation-name: crazyrighteye;

-ms-animation-name: crazyrighteye;

animation-name: crazyrighteye

}

#beast404le {

left: 125px;

top: 65px;

-webkit-animation-name: crazylefteye;

-moz-animation-name: crazylefteye;

-ms-animation-name: crazylefteye;

animation-name: crazylefteye

}

@-moz-keyframes crazylefteye {

0% { left: 125px; top: 65px}

10% { left: 118px; top: 56px}

20% { left: 118px; top: 56px}

40% { left: 148px; top: 62px}

50% {left: 145px;top: 72px}

60% {left: 121px;top: 70px}

70% {left: 125px;top: 65px}

100% {left: 125px;top: 65px}

}

@-webkit-keyframes crazylefteye {

0% {left: 125px;top: 65px}

10% {left: 118px;top: 56px}

20% {left: 118px;top: 56px}

40% {left: 148px;top: 62px}

50% {left: 145px;top: 72px}

60% {left: 121px;top: 70px}

70% {left: 125px;top: 65px}

100% {left: 125px;top: 65px}

}

@-o-keyframes crazylefteye {

0% {left: 125px;top: 65px}

10% {left: 118px;top: 56px}

20% {left: 118px;top: 56px}

40% {left: 148px;top: 62px}

50% {left: 145px;top: 72px}

60% {left: 121px;top: 70px}

70% {left: 125px;top: 65px}

100% {left: 125px;top: 65px}

}

@-ms-keyframes crazylefteye {

0% {left: 125px;top: 65px}

10% {left: 118px;top: 56px}

20% {left: 118px;top: 56px}

40% {left: 148px;top: 62px}

50% {left: 145px;top: 72px}

60% {left: 121px;top: 70px}

70% {left: 125px;top: 65px}

100% {left: 125px;top: 65px}

}

@keyframes crazylefteye {

0% {left: 125px;top: 65px}

10% {left: 118px;top: 56px}

20% {left: 118px;top: 56px}

40% {left: 148px;top: 62px}

50% {left: 145px;top: 72px}

60% {left: 121px;top: 70px}

70% {left: 125px;top: 65px}

100% {left: 125px;top: 65px}

}

@-moz-keyframes crazyrighteye {

0% {left: 231px;top: 68px}

10% {left: 212px;top: 62px}

20% {left: 212px;top: 62px}

40% {left: 239px;top: 64px}

50% {left: 240px;top: 80px}

60% {left: 215px;top: 73px}

70% {left: 231px;top: 68px}

100% {left: 231px;top: 68px}

}

@-webkit-keyframes crazyrighteye {

0% {left: 231px;top: 68px}

10% {left: 212px;top: 62px}

20% {left: 212px;top: 62px}

40% {left: 239px;top: 64px}

50% {left: 240px;top: 80px}

60% {left: 215px;top: 73px}

70% {left: 231px;top: 68px}

100% {left: 231px;top: 68px}

}

@-o-keyframes crazyrighteye {

0% {left: 231px;top: 68px}

10% {left: 212px;top: 62px}

20% {left: 212px;top: 62px}

40% {left: 239px;top: 64px}

50% {left: 240px;top: 80px}

60% {left: 215px;top: 73px}

70% {left: 231px;top: 68px}

100% {left: 231px;top: 68px}

}

@-ms-keyframes crazyrighteye {

0% {left: 231px;top: 68px}

10% {left: 212px;top: 62px}

20% {left: 212px;top: 62px}

40% {left: 239px;top: 64px}

50% {left: 240px;top: 80px}

60% {left: 215px;top: 73px}

70% {left: 231px;top: 68px}

100% {left: 231px;top: 68px}

}

@keyframes crazyrighteye {

0% {left: 231px;top: 68px}

10% {left: 212px;top: 62px}

20% {left: 212px;top: 62px}

40% {left: 239px;top: 64px}

50% {left: 240px;top: 80px}

60% {left: 215px;top: 73px}

70% {left: 231px;top: 68px}

100% {left: 231px;top: 68px}

}

 

转载于:https://www.cnblogs.com/papajia/p/4498197.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值