Are you ready to welcome 2026? Whether you are a web developer or a hobbyist looking to spice up your personal site, adding a live countdown timer is a fantastic way to build excitement.
In this tutorial, we will create a high-performance, mobile-responsive countdown timer. It features a "Glassmorphism" design, a glowing text effect, a festive fireworks background, and a music toggle button to set the mood!
Key Features of this Timer:
Live Precision: Ticks down every second until January 1, 2026.
Visual Flair: Golden neon glow effects and a semi-transparent glass UI.
Audio Support: A built-in music player that users can toggle on/off.
Responsive: Works perfectly on desktops, tablets, and smartphones.
Copy the Code Below
body {
/* High-quality Fireworks Background */
background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),
url('https://images.unsplash.com/photo-1467810563316-b5476525c0f9?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80');
background-size: cover;
background-position: center;
background-attachment: fixed;
color: white;
font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
overflow-x: hidden;
}
#music-control {
position: fixed;
top: 20px;
right: 20px;
background: rgba(255, 255, 255, 0.2);
border: 2px solid #ffd700;
color: #ffd700;
padding: 12px 20px;
border-radius: 50px;
cursor: pointer;
backdrop-filter: blur(5px);
font-weight: bold;
transition: all 0.3s ease;
z-index: 100;
}
#music-control:hover {
background: #ffd700;
color: black;
box-shadow: 0 0 15px #ffd700;
}
h1 {
font-size: clamp(2rem, 8vw, 4rem);
margin-bottom: 30px;
text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
letter-spacing: 5px;
text-align: center;
padding: 0 10px;
}
#countdown {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px;
}
.time-box {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(15px);
padding: 25px;
border-radius: 15px;
min-width: 120px;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
text-align: center;
}
.number {
display: block;
font-size: clamp(2.5rem, 6vw, 4.5rem);
font-weight: 800;
color: #ffd700;
text-shadow: 0 0 10px #ffcc00, 0 0 20px #ffae00;
animation: pulse 2s infinite;
}
.label {
font-size: 0.9rem;
text-transform: uppercase;
letter-spacing: 2px;
color: #efefef;
}
@keyframes pulse {
0% { transform: scale(1); text-shadow: 0 0 10px #ffcc00; }
50% { transform: scale(1.02); text-shadow: 0 0 25px #ffae00, 0 0 45px #ff4400; }
100% { transform: scale(1); text-shadow: 0 0 10px #ffcc00; }
}
COUNTDOWN TO 2026
00Days
00Hours
00Minutes
00Seconds
const audio = document.getElementById('bg-music');
const musicBtn = document.getElementById('music-control');
// Music Toggle Logic
musicBtn.addEventListener('click', () => {
if (audio.paused) {
audio.play();
musicBtn.innerText = "Pause Music";
} else {
audio.pause();
musicBtn.innerText = "Play Music 🎵";
}
});
const targetDate = new Date("Jan 1, 2026 00:00:00").getTime();
const updateCountdown = () => {
const now = new Date().getTime();
const distance = targetDate - now;
const d = Math.floor(distance / (1000 * 60 * 60 * 24));
const h = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const m = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const s = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("days").innerText = d.toString().padStart(2, '0');
document.getElementById("hours").innerText = h.toString().padStart(2, '0');
document.getElementById("minutes").innerText = m.toString().padStart(2, '0');
document.getElementById("seconds").innerText = s.toString().padStart(2, '0');
// NEW YEAR CELEBRATION TRIGGER
if (distance < 0) {
clearInterval(interval);
document.getElementById("title").innerText = "🎆 HAPPY NEW YEAR 2026! 🎆";
document.getElementById("countdown").innerHTML = "Wishing you a brilliant year ahead!
";
// Switch music to something more intense or increase volume
audio.volume = 1.0;
// You could change the audio source here to a "Fireworks" sound effect!
}
};
const interval = setInterval(updateCountdown, 1000);
updateCountdown();
