1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > CSS3动画</ title >
6+ < link type ="text/css " rel ="stylesheet " href ="css/reset.min.css "/>
7+ < style type ="text/css ">
8+ html , body {
9+ overflow : hidden;
10+ }
11+
12+ .box {
13+ position : absolute;
14+ top : 0 ;
15+ left : 0 ;
16+ right : 0 ;
17+ bottom : 0 ;
18+ margin : auto;
19+
20+ width : 200px ;
21+ height : 200px ;
22+
23+ /*--CSS3中的发射性背景颜色渐变--*/
24+ background : # 6699cc ;
25+ background : -webkit-radial-gradient (at right top, orange, red, green);
26+ background : -moz-radial-gradient (at right top, orange, red, green);
27+ background : -ms-radial-gradient (at right top, orange, red, green);
28+ background : -o-radial-gradient (at right top, orange, red, green);
29+ background : radial-gradient (at right top, orange, red, green);
30+
31+ /*--CSS3过渡动画:第一步给当前元素设置一个过渡的效果--*/
32+ /*-webkit-transition: all 1s linear 0s;
33+ -moz-transition: all 1s linear 0s;
34+ -o-transition: all 1s linear 0s;
35+ transition: all 1s linear 0s;*/
36+ }
37+
38+ /*--CSS3过渡动画:第二步触发元素的样式发生改变--*/
39+ /*.box:hover {
40+ -webkit-transform: scale(1.2);
41+ -moz-transform: scale(1.2);
42+ -o-transform: scale(1.2);
43+ -ms-transform: scale(1.2);
44+ transform: scale(1.2);
45+ }*/
46+
47+ /*--CSS3帧动画--*/
48+ /*--第一步:设置运动的轨迹/设置关键帧--*/
49+ /*@-webkit-keyframes myFirstMove {
50+ from {
51+ -webkit-transform: translate(0, 0);
52+ transform: translate(0, 0);
53+ }
54+ to {
55+ -webkit-transform: translate(-100px, 100px);
56+ transform: translate(-100px, 100px);
57+ }
58+ }
59+
60+ @keyframes myFirstMove {
61+ from {
62+ -webkit-transform: translate(0, 0);
63+ transform: translate(0, 0);
64+ }
65+ to {
66+ -webkit-transform: translate(-100px, 100px);
67+ transform: translate(-100px, 100px);
68+ }
69+ }*/
70+
71+ /*--第二步:触发动画执行--*/
72+ /*.box {
73+ -webkit-animation-name: myFirstMove;
74+ animation-name: myFirstMove;
75+
76+ -webkit-animation-duration: .5s;
77+ animation-duration: .5s;
78+
79+ -webkit-animation-timing-function: linear;
80+ animation-timing-function: linear;
81+
82+ -webkit-animation-delay: 0s;
83+ animation-delay: 0s;
84+
85+ /!*--当前动画运动的次数:infinite代表无限次运动--*!/
86+ -webkit-animation-iteration-count: 1;
87+ animation-iteration-count: 1;
88+
89+ /!*--animation属于模拟的帧动画,默认情况下动画运动完成会回到第一帧的位置(本质是虽然看到元素在运动,但是元素的位置其实是没有变化的),如果想要让动画运动完成停留在最后一帧的位置,我们需要增加如下的属性--*!/
90+ -webkit-animation-fill-mode: both;
91+ animation-fill-mode: both;
92+ }*/
93+
94+ @-webkit-keyframes myTwoMove {
95+ 0% , 50% , 100% {
96+ -webkit-transform : translateX (0 ) rotate (0deg );
97+ transform : translateX (0 ) rotate (0deg );
98+ }
99+ 25% {
100+ -webkit-transform : translateX (-200px ) rotate (-360deg );
101+ transform : translateX (-200px ) rotate (-360deg );
102+ }
103+ 75% {
104+ -webkit-transform : translateX (200px ) rotate (360deg );
105+ transform : translateX (200px ) rotate (360deg );
106+ }
107+ }
108+
109+ @keyframes myTwoMove {
110+ 0% , 50% , 100% {
111+ -webkit-transform : translateX (0 ) rotate (0deg );
112+ transform : translateX (0 ) rotate (0deg );
113+ }
114+ 25% {
115+ -webkit-transform : translateX (-200px ) rotate (-360deg );
116+ transform : translateX (-200px ) rotate (-360deg );
117+ }
118+ 75% {
119+ -webkit-transform : translateX (200px ) rotate (360deg );
120+ transform : translateX (200px ) rotate (360deg );
121+ }
122+ }
123+
124+ .box {
125+ border-radius : 50% ;
126+ -webkit-animation : myTwoMove 2s linear 0s infinite both;
127+ animation : myTwoMove 2s linear 0s infinite both;
128+ }
129+ </ style >
130+ </ head >
131+ < body >
132+ < div class ="box "> </ div >
133+
134+ </ body >
135+ </ html >
0 commit comments