-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex3.html
More file actions
242 lines (199 loc) · 6.68 KB
/
index3.html
File metadata and controls
242 lines (199 loc) · 6.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Happy Birthday</title>
<style>
body {
background-color: rgba(240, 63, 93, 0.226);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
font-family: sans-serif;
overflow: hidden;
}
.cake {
position: relative;
width: 200px;
margin-bottom: 20px;
}
.layer {
display: flex;
height: 60px;
}
.half {
width: 50%;
transition: transform 1s ease;
}
.layer1 .left,
.layer1 .right {
background-color: #d1c4e9;
}
.layer2 .left,
.layer2 .right {
background-color: #9575cd;
}
.layer3 .left,
.layer3 .right {
background-color: #512da8;
}
.layer1 .left,
.layer2 .left,
.layer3 .left {
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
}
.layer1 .right,
.layer2 .right,
.layer3 .right {
border-top-right-radius: 20px;
border-bottom-right-radius: 20px;
}
.candle {
position: absolute;
top: -50px;
left: 50%;
transform: translateX(-50%);
width: 10px;
height: 50px;
background: #333;
border-radius: 2px;
}
.flame {
position: absolute;
top: -15px;
left: 50%;
width: 30px;
height: 30px;
background: orange;
border-radius: 50% 0% 50% 50%;
transform: translateX(-50%) rotate(45deg);
animation: flicker 0.3s infinite alternate;
z-index: 1;
}
@keyframes flicker {
0% {
transform: translateX(-50%) rotate(-45deg) scale(1);
opacity: 1;
}
100% {
transform: translateX(-50%) rotate(-45deg) scale(1.2);
opacity: 0.8;
}
}
.cut .left {
transform: translateX(-60px);
}
.cut .right {
transform: translateX(60px);
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
.confetti {
position: absolute;
bottom: 0;
left: 50%;
/* Start from center */
width: 8px;
height: 8px;
background-color: red;
border-radius: 50%;
animation: popper 1.8s ease-out forwards;
transform: translateX(-50%);
pointer-events: none;
}
@keyframes popper {
0% {
transform: translate(-50%, 0) scale(1) rotate(0deg);
opacity: 1;
}
70% {
transform: translate(calc(-50% + var(--spread-x)), calc(-300px + var(--spread-y))) scale(1.5) rotate(180deg);
}
100% {
transform: translate(calc(-50% + var(--spread-x)), calc(-400px + var(--spread-y))) scale(0.8) rotate(360deg);
opacity: 0;
}
}
</style>
</head>
<body>
<div class="cake" id="cake">
<div class="candle" id="candle">
<div class="flame" id="flame"></div>
</div>
<div class="layer layer1">
<div class="half left"></div>
<div class="half right"></div>
</div>
<div class="layer layer2">
<div class="half left"></div>
<div class="half right"></div>
</div>
<div class="layer layer3">
<div class="half left"></div>
<div class="half right"></div>
</div>
</div>
<button id="actionBtn" onclick="handleClick()">Blow</button>
<div class="bless"></div>
<script>
let state = "blow";
function handleClick() {
const flame = document.getElementById("flame");
const btn = document.getElementById("actionBtn");
const cake = document.getElementById("cake");
const song = document.getElementById("birthdaySong");
if (state === "blow") {
flame.style.display = "none";
btn.textContent = "Cut";
state = "cut";
} else if (state === "cut") {
cake.classList.add("cut");
btn.disabled = true;
launchConfetti();
setTimeout(() => {
document.getElementById("wishMessage").style.display = "block";
}, 1800);
song.play().catch(err => {
console.warn("Playback blocked:", err);
const p = document.createElement("button");
p.textContent = "🎵 Play Birthday Song";
p.onclick = () => song.play();
document.body.appendChild(p);
});
}
}
function launchConfetti() {
for (let i = 0; i < 80; i++) {
const confetti = document.createElement("div");
confetti.className = "confetti";
confetti.style.backgroundColor = getRandomColor();
// Full width spread: -50vw to +50vw from center
const spreadX = Math.random() * window.innerWidth - window.innerWidth / 2;
const spreadY = Math.random() * 150 - 75;
confetti.style.setProperty("--spread-x", `${spreadX}px`);
confetti.style.setProperty("--spread-y", `${spreadY}px`);
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 2500);
}
}
function getRandomColor() {
const colors = ["#f44336", "#e91e63", "#9c27b0", "#2196f3", "#4caf50", "#ffeb3b", "#ff9800"];
return colors[Math.floor(Math.random() * colors.length)];
}
function playCelebration() {
const audio = document.getElementById("celebrationSound");
audio.play();
}
</script>
<h2 id="wishMessage" style="display:none; margin-top: 60px; color:#e20f6a; font-size: 40px;">
MAY YOU ALWAYS WIN AND SHINE IN LIFE
</h2>
</body>
</html>