-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path13css.html
More file actions
219 lines (213 loc) · 5.68 KB
/
13css.html
File metadata and controls
219 lines (213 loc) · 5.68 KB
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-D0ENCWPZL9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-D0ENCWPZL9');
</script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>13. CSS Animations</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body, html {
height: 100%;
font-family: 'Poppins', sans-serif;
background: linear-gradient(to right, #43cea2, #185a9d);
color: #333;
overflow-x: hidden;
}
.section {
background: rgba(255,255,255,0.15);
margin: 20px auto;
padding: 20px;
border-radius: 14px;
width: 90%;
max-width: 1000px;
box-shadow: 0 8px 20px rgba(0,0,0,0.3);
backdrop-filter: blur(6px);
}
h2 {
font-size: 28px;
margin-bottom: 20px;
color: white;
text-align: center;
}
h3 {
color: #fff;
margin-top: 30px;
margin-bottom: 10px;
}
p, ul {
font-size: 17px;
color: #f1f1f1;
line-height: 1.6;
margin-bottom: 15px;
}
textarea {
width: 100%;
height: 150px;
padding: 12px;
font-size: 16px;
font-family: monospace;
background-color: rgba(255, 255, 255, 0.1);
border: 2px solid #fff;
border-radius: 10px;
color: #fff;
margin-bottom: 10px;
}
iframe {
width: 100%;
height: 150px;
background: rgba(0,0,0,0.1);
border: 2px solid white;
border-radius: 10px;
margin-top: 10px;
}
button {
padding: 8px 18px;
font-size: 15px;
font-weight: 500;
background-color: #ff5722;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
transition: transform 0.2s, background-color 0.3s;
margin-bottom: 20px;
}
button:hover {
background-color: #e64a19;
transform: scale(1.05);
}
button:active {
transform: scale(0.97);
}
</style>
</head>
<body>
<div class="section">
<h2>13. CSS Animations</h2>
<h3>I. @keyframes</h3>
<p><strong>Explanation:</strong> <code>@keyframes</code> se hum animation ka flow define karte hain — jaise element kaise start karega aur kaise end karega.</p>
<textarea id="code1">
<style>
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.box {
width: 150px;
height: 150px;
background: orange;
animation: fadeIn 2s ease-in-out;
}
</style>
<div class="box"></div>
</textarea>
<button onclick="runCode('code1', 'output1')">Run Code</button>
<iframe id="output1"></iframe>
<h3>II. Animation Properties</h3>
<p><strong>Explanation:</strong> Animation ke liye kuch important properties hote hain:
<ul>
<li><code>animation-name</code>: @keyframes ka naam</li>
<li><code>animation-duration</code>: Animation kitni der chale</li>
<li><code>animation-delay</code>: Kab start ho</li>
<li><code>animation-iteration-count</code>: Kitni baar chale</li>
<li><code>animation-direction</code>: normal, reverse, alternate</li>
<li><code>animation-fill-mode</code>: Animation ke baad element ka state</li>
</ul>
</p>
<textarea id="code2">
<style>
@keyframes moveRight {
from { transform: translateX(0); }
to { transform: translateX(200px); }
}
.box {
width: 100px;
height: 100px;
background: #3498db;
animation-name: moveRight;
animation-duration: 3s;
animation-delay: 0.5s;
animation-iteration-count: 2;
animation-direction: alternate;
animation-fill-mode: forwards;
}
</style>
<div class="box"></div>
</textarea>
<button onclick="runCode('code2', 'output2')">Run Code</button>
<iframe id="output2"></iframe>
<h3>III. Animation Timing Functions</h3>
<p><strong>Explanation:</strong> Timing functions define karti hain animation ki speed curve — jaise slow start, fast end, etc.
<ul>
<li><code>linear</code></li>
<li><code>ease</code></li>
<li><code>ease-in</code></li>
<li><code>ease-out</code></li>
<li><code>ease-in-out</code></li>
</ul>
</p>
<textarea id="code3">
<style>
@keyframes bounce {
0% { transform: translateY(0); }
50% { transform: translateY(-60px); }
100% { transform: translateY(0); }
}
.ball {
width: 50px;
height: 50px;
background: crimson;
border-radius: 50%;
animation: bounce 1s ease-in-out infinite;
}
</style>
<div class="ball"></div>
</textarea>
<button onclick="runCode('code3', 'output3')">Run Code</button>
<iframe id="output3"></iframe>
<h3>IV. Infinite Loop Animations</h3>
<p><strong>Explanation:</strong> Jab aapko animation continuously chahiye ho, to <code>animation-iteration-count: infinite;</code> use karte hain.</p>
<textarea id="code4">
<style>
@keyframes rotate360 {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.loader {
width: 60px;
height: 60px;
border: 6px solid lightgray;
border-top: 6px solid #1cc9be;
border-radius: 50%;
animation: rotate360 1s linear infinite;
}
</style>
<div class="loader"></div>
</textarea>
<button onclick="runCode('code4', 'output4')">Run Code</button>
<iframe id="output4"></iframe>
</div>
<script>
function runCode(textareaId, iframeId) {
const code = document.getElementById(textareaId).value;
const iframe = document.getElementById(iframeId);
const doc = iframe.contentDocument || iframe.contentWindow.document;
doc.open();
doc.write(code);
doc.close();
}
</script>
</body>
</html>