keyframes 放大缩小动画

Posted JeremyLee87

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了keyframes 放大缩小动画相关的知识,希望对你有一定的参考价值。

本次项目中动画放大缩小代码小结

.fix .phone{ -moz-animation: myfirst 1s infinite; -webkit-animation: myfirst 1s infinite; -o-animation: myfirst 1s infinite; animation: myfirst 1s infinite;}
@keyframes myfirst{
0% { transform: scale(.8); }
50% { transform: scale(1); }
100% { transform: scale(.8); }
}
@-moz-keyframes myfirst{
0%	{-moz-transform: scale(.8);}
50%	{-moz-transform: scale(1);}
100%	{-moz-transform: scale(.8);}
}
@-webkit-keyframes myfirst{
0%	{-webkit-transform: scale(.8);}
50%	{-webkit-transform: scale(1);}
100%	{-webkit-transform: scale(.8);}
}

@-o-keyframes myfirst{
0%	{-o-transform: scale(.8);}
50%	{-o-transform: scale(1);}
100%	{-o-transform: scale(.8);}
}

  参考代码:

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <style> 
 5 div
 6 {
 7 width:100px;
 8 height:100px;
 9 background:red;
10 position:relative;
11 animation:mymove 5s infinite;
12 -moz-animation:mymove 5s infinite; /* Firefox */
13 -webkit-animation:mymove 5s infinite; /* Safari and Chrome */
14 -o-animation:mymove 5s infinite; /* Opera */
15 }
16 
17 @keyframes mymove
18 {
19 0%   {top:0px; left:0px; background:red;}
20 25%  {top:0px; left:100px; background:blue;}
21 50%  {top:100px; left:100px; background:yellow;}
22 75%  {top:100px; left:0px; background:green;}
23 100% {top:0px; left:0px; background:red;}
24 }
25 
26 @-moz-keyframes mymove /* Firefox */
27 {
28 0%   {top:0px; left:0px; background:red;}
29 25%  {top:0px; left:100px; background:blue;}
30 50%  {top:100px; left:100px; background:yellow;}
31 75%  {top:100px; left:0px; background:green;}
32 100% {top:0px; left:0px; background:red;}
33 }
34 
35 @-webkit-keyframes mymove /* Safari and Chrome */
36 {
37 0%   {top:0px; left:0px; background:red;}
38 25%  {top:0px; left:100px; background:blue;}
39 50%  {top:100px; left:100px; background:yellow;}
40 75%  {top:100px; left:0px; background:green;}
41 100% {top:0px; left:0px; background:red;}
42 }
43 
44 @-o-keyframes mymove /* Opera */
45 {
46 0%   {top:0px; left:0px; background:red;}
47 25%  {top:0px; left:100px; background:blue;}
48 50%  {top:100px; left:100px; background:yellow;}
49 75%  {top:100px; left:0px; background:green;}
50 100% {top:0px; left:0px; background:red;}
51 }
52 </style>
53 </head>
54 <body>
55 
56 <p><b>注释:</b>本例在 Internet Explorer 中无效。</p>
57 
58 <div></div>
59 
60 </body>
61 </html>

 

以上是关于keyframes 放大缩小动画的主要内容,如果未能解决你的问题,请参考以下文章

如何在颤动中缩小和放大图标动画?

滑动桌面放大/缩小查看动画

Android之实现点击布局缩小然后再放大动画

Android之实现点击布局缩小然后再放大动画

在 iPhone 中以编程方式放大和缩小:如何设置动画速度?

mapkit 缩小然后放大