Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>Festive Celebration</title>
  <!-- Fonts -->
  <link href="https://fonts.googleapis.com/css2?family=Great+Vibes&family=Montserrat:wght@400;700&display=swap" rel="stylesheet">
</head>
<body>
  <div class="background"></div>

  <div class="container">
    <h1 class="title">Celebration</h1>
    <div class="countdown-container">
      <h2 class="countdown-title">New Year in:</h2>
      <div class="countdown" id="countdown">
        <span id="days">00</span>d 
        <span id="hours">00</span>h 
        <span id="minutes">00</span>m 
        <span id="seconds">00</span>s
      </div>
    </div>
    
    <div class="scene">
      <div class="tree">
        <div class="star"></div>
        <div class="layer layer1"></div>
        <div class="layer layer2"></div>
        <div class="layer layer3"></div>
        <div class="trunk"></div>
      </div>
      <div class="garlands">
        <div class="garland"></div>
        <div class="garland"></div>
        <div class="garland"></div>
      </div>
    </div>

    <button class="celebrate-btn" id="celebrateBtn">Celebrate!</button>
    <div class="gift-container">
      <div class="gift" id="gift">
        <div class="gift-lid"></div>
        <div class="gift-box"></div>
        <div class="ribbon ribbon-vertical"></div>
        <div class="ribbon ribbon-horizontal"></div>
      </div>
      <div class="gift-message" id="giftMessage">
        <p>Happy Holidays and Best Wishes!</p>
      </div>
    </div>
    
    <div class="text-animation">
      <span class="letter">E</span>
      <span class="letter">N</span>
      <span class="letter">J</span>
      <span class="letter">O</span>
      <span class="letter">Y</span>
      <span class="letter">!</span>
    </div>
  </div>

  <!-- tsParticles container -->
  <div id="tsparticles"></div>

  <!-- Confetti container -->
  <div class="confetti-container" id="confettiContainer"></div>

  <script src="https://cdn.jsdelivr.net/npm/tsparticles@2/tsparticles.bundle.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

              
            
!

CSS

              
                body {
  margin: 0;
  padding: 0;
  background: #0b0b2a;
  font-family: 'Montserrat', sans-serif;
  color: #fff;
  overflow-x: hidden;
}

.background {
  position: fixed;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(to bottom, #0b0b2a, #1a1a3d);
  z-index: -2;
}

.container {
  position: relative;
  text-align: center;
  padding: 50px 20px;
}

.title {
  font-family: 'Great Vibes', cursive;
  font-size: 4rem;
  margin: 20px 0;
  color: #fbd500;
  animation: glow 2s infinite alternate;
}

/* Compte à rebours */
.countdown-container {
  margin: 20px 0;
}

.countdown-title {
  font-size: 1.5rem;
  margin-bottom: 10px;
  color: #fbd500;
}

.countdown {
  font-size: 1.2rem;
}

/* Scene festive */
.scene {
  margin: 50px auto;
  width: 200px;
  position: relative;
}

/* Sapin */
.tree {
  position: relative;
  margin: 0 auto;
  width: 0; 
  height: 0;
}

.tree .star {
  position: absolute;
  top: -30px;
  left: -15px;
  width: 30px;
  height: 30px;
  background: radial-gradient(circle, #fbd500 0%, #fbd500 60%, transparent 70%);
  border-radius: 50%;
  animation: twinkle 2s infinite alternate;
}

.tree .layer {
  border-left: 50px solid transparent;
  border-right: 50px solid transparent;
  display: block;
  margin: 0 auto;
}

.layer1 {
  border-bottom: 40px solid #1e9e2b;
}

.layer2 {
  border-bottom: 60px solid #1e9e2b;
  margin-top: -20px;
}

.layer3 {
  border-bottom: 80px solid #1e9e2b;
  margin-top: -30px;
}

.trunk {
  width: 20px;
  height: 30px;
  background: #7b4f1b;
  margin: -5px auto 0 auto;
}

/* Guirlandes */
.garlands {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
}

.garland {
  width: 100%;
  height: 2px;
  background: rgba(255,255,255,0.5);
  margin: 15px 0;
  position: relative;
  overflow: visible;
  animation: glowGuirlande 2s infinite alternate;
}

.garland::before, .garland::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  background: #fbd500;
  border-radius: 50%;
  top: -2px;
  animation: twinkle 2s infinite alternate;
}

.garland::before {
  left: 20px;
}
.garland::after {
  right: 20px;
}

/* Bouton Célébrer */
.celebrate-btn {
  margin: 30px 0;
  background: #fbd500;
  color: #0b0b2a;
  border: none;
  font-size: 1.2rem;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.3s;
  border-radius: 5px;
}

.celebrate-btn:hover {
  background: #ffe600;
}

/* Cadeau */
.gift-container {
  position: relative;
  margin: 40px auto;
  width: 100px;
  height: 100px;
  perspective: 800px;
}

.gift {
  position: absolute;
  width: 100px;
  height: 100px;
  transform-style: preserve-3d;
  transform: translateZ(0);
  cursor: pointer;
  transition: transform 0.7s ease;
}

.gift-lid {
  position: absolute;
  width: 100px;
  height: 20px;
  background: #fbd500;
  top: 0;
}

.gift-box {
  position: absolute;
  width: 100px;
  height: 100px;
  background: #f63c3c;
  transform: translateY(10px);
  box-sizing: border-box;
  border: 2px solid #fff;
}

.ribbon {
  position: absolute;
  background: #fff;
}

.ribbon-vertical {
  width: 10px;
  height: 100px;
  left: 45px;
  top: 0;
}

.ribbon-horizontal {
  width: 100px;
  height: 10px;
  top: 45px;
  left: 0;
}

.gift.opened {
  transform: rotateX(-40deg) translateY(-50px);
}

/* Message cadeau */
.gift-message {
  position: absolute;
  top: 120px;
  width: 100%;
  text-align: center;
  opacity: 0;
  transition: opacity 1s ease;
  font-size: 1rem;
  color: #fbd500;
}

.gift.opened ~ .gift-message {
  opacity: 1;
}

/* Animation texte "BRAVO!" */
.text-animation {
  font-size: 3rem;
  margin-top: 50px;
  display: inline-block;
  font-weight: bold;
  overflow: hidden;
  white-space: nowrap;
}

.text-animation .letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(-100%);
  animation: dropLetter 1.5s ease forwards;
}
.text-animation .letter:nth-child(1) { animation-delay: 0s; }
.text-animation .letter:nth-child(2) { animation-delay: 0.1s; }
.text-animation .letter:nth-child(3) { animation-delay: 0.2s; }
.text-animation .letter:nth-child(4) { animation-delay: 0.3s; }
.text-animation .letter:nth-child(5) { animation-delay: 0.4s; }
.text-animation .letter:nth-child(6) { animation-delay: 0.5s; }

/* Confettis */
.confetti-container {
  pointer-events: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  overflow: hidden;
  z-index: 9999;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fbd500;
  animation: fall 3s linear forwards;
}

.confetti.blue {
  background: #3cf6f3;
}
.confetti.red {
  background: #f63c3c;
}
.confetti.green {
  background: #3cf64b;
}

@keyframes fall {
  to {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0;
  }
}

@keyframes glow {
  from {
    text-shadow: 0 0 10px #fbd500;
  }
  to {
    text-shadow: 0 0 20px #ffef70;
  }
}

@keyframes twinkle {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.4;
  }
}

@keyframes glowGuirlande {
  from {
    background: rgba(255,255,255,0.5);
  }
  to {
    background: rgba(255,255,255,0.9);
  }
}

@keyframes dropLetter {
  0% {transform: translateY(-100%); opacity: 0;}
  60% {opacity: 1;}
  100% {transform: translateY(0); opacity:1;}
}

              
            
!

JS

              
                // --- New Year Countdown ---
function updateCountdown() {
  const now = new Date();
  const nextYear = now.getFullYear() + 1;
  const newYear = new Date(nextYear, 0, 1, 0, 0, 0);
  const diff = newYear - now;

  const days = Math.floor(diff / (1000 * 60 * 60 * 24));
  const hours = Math.floor((diff / (1000 * 60 * 60)) % 24);
  const minutes = Math.floor((diff / (1000 * 60)) % 60);
  const seconds = Math.floor((diff / 1000) % 60);

  document.getElementById('days').textContent = String(days).padStart(2, '0');
  document.getElementById('hours').textContent = String(hours).padStart(2, '0');
  document.getElementById('minutes').textContent = String(minutes).padStart(2, '0');
  document.getElementById('seconds').textContent = String(seconds).padStart(2, '0');
}

setInterval(updateCountdown, 1000);
updateCountdown();

// --- tsParticles Fireworks ---
tsParticles.load("tsparticles", {
  "fullScreen": {
    "enable": true,
    "zIndex": -1
  },
  "particles": {
    "number": {
      "value": 0
    },
    "shape": {
      "type": "circle"
    },
    "color": {
      "value": "#fbd500"
    },
    "size": {
      "value": 3,
      "random": true
    },
    "move": {
      "enable": true,
      "speed": 6,
      "out_mode": "destroy",
      "straight": false
    },
    "line_linked": {
      "enable": false
    }
  },
  "interactivity": {
    "events": {
      "onclick": {
        "enable": true,
        "mode": "explode"
      }
    },
    "modes": {
      "explode": {
        "particles": {
          "min": 20,
          "max": 40
        }
      }
    }
  },
  "background": {
    "image": "url('https://i.ibb.co/yXHcNwh/DALL-E-2024-12-13-18-14-01-A-vibrant-New-Year-countdown-scene-with-fireworks-bursting-in-a-starry-ni.png')",
    "position": "center",
    "repeat": "no-repeat",
    "size": "cover"
  }
});

// Fireworks are already triggered on click by tsParticles, no additional code needed
document.body.addEventListener('click', () => {
  // No extra code needed here
});

// --- Confetti ---
const celebrateBtn = document.getElementById('celebrateBtn');
const confettiContainer = document.getElementById('confettiContainer');

celebrateBtn.addEventListener('click', () => {
  triggerConfetti();
});

function triggerConfetti() {
  for (let i = 0; i < 100; i++) {
    const confetti = document.createElement('div');
    confetti.classList.add('confetti');
    // Random colors
    const colors = ['blue','red','green'];
    confetti.classList.add(colors[Math.floor(Math.random()*colors.length)]);

    confetti.style.left = Math.random() * 100 + 'vw';
    confetti.style.animationDuration = (Math.random() * 3 + 2) + 's';
    confettiContainer.appendChild(confetti);

    setTimeout(() => {
      confetti.remove();
    }, 5000);
  }
}

// --- Surprise Gift ---
const gift = document.getElementById('gift');
gift.addEventListener('click', () => {
  gift.classList.toggle('opened');
  // Trigger additional confetti when the gift is opened
  triggerConfetti();
});

              
            
!
999px

Console