Pesta kembang api merah, putih, dan emas di atas kampung berhias umbul-umbul, digambar di canvas dengan partikel bergravitasi (paling banyak 300). Klik langit…
Oleh @belajarweb · JavaScript
<!doctype html>
<html lang="id">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Kembang Api 17-an</title>
<style>
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
background: #070a22;
color: #f4efe6;
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
-webkit-tap-highlight-color: transparent;
}
.malam {
--kampung-h: clamp(220px, 50vh, 360px);
position: relative; width: 100%; height: 100%; overflow: hidden;
background:
radial-gradient(ellipse 70% 32% at 50% 100%, rgba(255,120,90,.28), rgba(255,120,90,0) 70%),
linear-gradient(#050720, #0d1240 40%, #22195a 72%, #3a2058);
cursor: crosshair;
touch-action: manipulation;
user-select: none; -webkit-user-select: none;
}
.bintang {
position: absolute; inset: 0 0 30% 0;
background:
radial-gradient(1.4px 1.4px at 12% 18%, #fff 50%, rgba(255,255,255,0)),
radial-gradient(1px 1px at 26% 42%, #fff 50%, rgba(255,255,255,0)),
radial-gradient(1.6px 1.6px at 38% 12%, #fff 50%, rgba(255,255,255,0)),
radial-gradient(1px 1px at 55% 30%, #fff 50%, rgba(255,255,255,0)),
radial-gradient(1.3px 1.3px at 68% 9%, #fff 50%, rgba(255,255,255,0)),
radial-gradient(1px 1px at 79% 38%, #fff 50%, rgba(255,255,255,0)),
radial-gradient(1.5px 1.5px at 90% 20%, #fff 50%, rgba(255,255,255,0)),
radial-gradient(1px 1px at 6% 52%, #fff 50%, rgba(255,255,255,0)),
radial-gradient(1.2px 1.2px at 46% 56%, #fff 50%, rgba(255,255,255,0)),
radial-gradient(1px 1px at 96% 60%, #fff 50%, rgba(255,255,255,0));
opacity: .75;
animation: kerlip 4s ease-in-out infinite alternate;
}
@keyframes kerlip { to { opacity: .4; } }
.kilat { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
#langit { position: absolute; left: 0; top: 0; display: block; }
.judul {
position: absolute; left: 0; right: 0; top: 9%;
text-align: center; pointer-events: none;
}
.kecil {
display: inline-flex; align-items: center; gap: .7em; margin: 0;
font-size: clamp(12px, 1.6vw, 15px); font-weight: 700; letter-spacing: .24em; text-transform: uppercase;
color: rgba(244,239,230,.8);
opacity: 0; animation: muncul 1s ease-out .2s forwards;
}
.bendera-kecil { display: inline-block; width: 1.6em; height: 1.05em; border-radius: 2px; background: linear-gradient(#e63a3a 50%, #f4efe6 50%); box-shadow: 0 0 10px rgba(230,58,58,.5); }
.judul h1 {
margin: .08em 0 0;
font-family: "Didot", "Bodoni 72", "Bodoni MT", "Playfair Display", Georgia, "Times New Roman", serif;
font-size: clamp(54px, 11.5vw, 128px); font-style: italic; font-weight: 700; line-height: 1.05;
letter-spacing: -.01em;
background: linear-gradient(#fff8dc 8%, #ffd36b 46%, #f2a33a 70%, #ffe7a8 92%);
-webkit-background-clip: text; background-clip: text; color: transparent;
filter: drop-shadow(0 0 18px rgba(255,190,90,.45)) drop-shadow(0 4px 0 rgba(90,20,30,.6));
opacity: 0;
animation: dirgahayu 1.8s cubic-bezier(.2,.7,.2,1) .35s forwards;
}
@keyframes dirgahayu {
from { opacity: 0; transform: translateY(18px) scale(.94); letter-spacing: .08em; }
to { opacity: 1; transform: none; letter-spacing: -.01em; }
}
@keyframes muncul { to { opacity: 1; } }
.kampung { position: absolute; left: 0; bottom: 0; width: 100%; height: var(--kampung-h); display: block; pointer-events: none; }
.tv { animation: tv 2.6s steps(6, jump-none) infinite; }
@keyframes tv { 0% { opacity: .9; } 20% { opacity: .55; } 40% { opacity: 1; } 60% { opacity: .7; } 80% { opacity: .95; } 100% { opacity: .6; } }
.umbul-kain { transform-box: fill-box; transform-origin: 50% 0; animation: kibar 3.4s ease-in-out infinite alternate; }
.umbul-kanan .umbul-kain { animation-delay: -1.7s; }
.kibar { transform-box: fill-box; transform-origin: 0 50%; animation: kibar-bendera 1.4s ease-in-out infinite alternate; }
@keyframes kibar { from { transform: skewX(-5deg); } to { transform: skewX(6deg) scaleY(.97); } }
@keyframes kibar-bendera { from { transform: skewY(-6deg) scaleX(.92); } to { transform: skewY(5deg); } }
.bawah {
position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
display: flex; align-items: center; justify-content: space-between; gap: 12px;
padding: 0 clamp(14px, 3vw, 28px) clamp(12px, 2.4vh, 20px);
pointer-events: none;
}
.petunjuk { margin: 0; font-size: clamp(12px, 1.5vw, 14px); font-weight: 600; color: rgba(244,239,230,.85); text-shadow: 0 1px 3px #000, 0 0 10px #070a22; }
.pakai-sentuh { display: none; }
@media (hover: none) { .pakai-sentuh { display: inline; } .pakai-tetikus { display: none; } }
.nyalakan {
pointer-events: auto;
display: inline-flex; align-items: center; gap: 8px; flex: none;
padding: 10px 18px 10px 14px; border: 0; border-radius: 99px; cursor: pointer;
font: 800 15px/1 system-ui, -apple-system, "Segoe UI", sans-serif; color: #fff;
background: linear-gradient(#ff5a52, #d42a35);
box-shadow: 0 4px 0 #7d1220, 0 0 0 2px rgba(255,255,255,.85), 0 10px 24px rgba(214,42,53,.45);
transition: transform .08s, box-shadow .08s;
}
.nyalakan:active { transform: translateY(3px); box-shadow: 0 1px 0 #7d1220, 0 0 0 2px rgba(255,255,255,.85); }
.nyalakan:focus { outline: none; }
.nyalakan:focus-visible { box-shadow: 0 4px 0 #7d1220, 0 0 0 3px #ffd36b, 0 10px 24px rgba(214,42,53,.45); }
.nyalakan svg { width: 18px; height: 18px; fill: none; stroke: #ffe7a8; stroke-width: 2.4; stroke-linecap: round; }
@media (max-width: 560px) {
.judul { top: 7%; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
</style>
</head>
<body>
<main class="malam" id="malam">
<div class="bintang" aria-hidden="true"></div>
<div class="kilat" id="kilat" aria-hidden="true"></div>
<canvas id="langit" role="img" aria-label="Kembang api merah, putih, dan emas di atas langit kampung"></canvas>
<header class="judul">
…