-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimations_keyframes_and_Transitions.html
161 lines (130 loc) · 3.42 KB
/
Animations_keyframes_and_Transitions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Animations, keyframes and Transitions</title>
<style>
* {
box-sizing: border-box;
}
.container {
border: 4px solid rgb(0, 13, 128);
height: 100vh;
display: flex;
flex-direction: column;
}
/* .element {
animation-name: stretch;
animation-duration: 1.5s;
animation-timing-function: ease-out;
animation-delay: 0s;
animation-direction: alternate;
animation-iteration-count: infinite;
animation-fill-mode: none;
animation-play-state: running;
}
is the same as:
.element {
animation:
stretch 1.5s ease-out 0s alternate infinite none running; }
Also,
Performance:
**********
Animating most properties is a performance concern, so we should proceed with caution before animating any property. However, there are certain combinations that can be animated safely:
transform: translate()
transform: scale()
transform: rotate()
opacity
*****************
*/
#box1 {
border: 3px solid rgb(153, 44, 111);
height: 200px;
width: 200px;
background-color: palegreen;
position: relative;
top: 15%;
animation-name: nik1;
animation-duration: 3s;
animation-iteration-count: infinite;
}
#box2 {
border: 3px solid rgb(153, 44, 111);
height: 200px;
width: 200px;
margin-top: 80px;
background-color: paleturquoise;
position: relative;
top: 15%;
animation-name: nik2;
animation-duration: 3s;
animation-iteration-count: infinite;
}
#box3 {
border: 3px solid rgb(153, 44, 111);
height: 200px;
width: 200px;
margin-top: 80px;
background-color: plum;
position: relative;
top: 15%;
}
#box3:hover {
border: 3px solid rgb(153, 44, 111);
height: 200px;
width: 200px;
margin-top: 80px;
background-color: rgb(160, 166, 221);
position: relative;
top: 15%;
animation-name: keyframe_test;
animation-duration: 3s;
animation-iteration-count: infinite;
transition: 0.5s;
}
@keyframes keyframe_test {
from {
width: 200px;
}
to {
width: 70vw;
}
}
@keyframes nik1 {
from {
width: 200px;
}
to {
width: 500px;
}
}
@keyframes nik2 {
0% {
top: 0px;
left: 0px;
}
25% {
top: 100px;
left: 0px;
}
75% {
top: 100px;
left: 100px;
}
100% {
top: 0px;
left: 100px;
}
}
</style>
</head>
<body>
<div class="container">
<div id="box2">This is a box for animations</div>
<div id="box1">This is a box for animations</div>
<div id="box3">Click Me</div>
</div>
</body>
</html>