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

              
                <div id="app">
      <div class="christmas-theme">
        <div class="snowfall-container"></div>
        <div class="lights-container"></div>
        <div class="santa">🎅</div>
        <div class="content">
          <div class="header">
            <h1 class="title">Merry Christmas</h1>
            <p class="subtitle">Ho Ho Ho! Happy Holidays!</p>
          </div>

          <div class="scene">
            <div class="moon">🌕</div>
            <div class="tree">
              <div class="star">⭐</div>
              <div class="branch">🎄</div>
              <div class="branch">🎄🎄</div>
              <div class="branch">🎄🎄🎄</div>
              <div class="branch">🎄🎄🎄🎄</div>
              <div class="branch">🎄🎄🎄🎄🎄</div>
              <div class="branch">🎄🎄🎄🎄🎄🎄</div>
              <div class="branch">🎄🎄🎄🎄🎄🎄🎄</div>
              <div class="branch">🎄🎄🎄🎄🎄🎄🎄🎄</div>
              <div class="trunk">🪵</div>
            </div>

            <div class="decorations">
              <div class="candy-cane">🍬</div>
              <div class="bell">🔔</div>
            </div>
          </div>

          <div class="controls">
            <button class="music-toggle">🎵 Christmas Carols</button>
          </div>
        </div>
      </div>
    </div>
              
            
!

CSS

              
                :root {
  --christmas-red: #D42426;
  --christmas-green: #0F5738;
  --gold: #FFD700;
  --snow-white: #FFFFFF;
  --night-sky: #0A1128;
  --text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  --font-size-xl: clamp(2.5rem, 5vw, 4rem);
  --font-size-lg: clamp(1.2rem, 3vw, 1.5rem);
  --font-size-md: clamp(1rem, 2vw, 1.2rem);
  --font-size-sm: clamp(0.875rem, 1.5vw, 1rem);
  --spacing-xs: clamp(0.5rem, 1vw, 0.75rem);
  --spacing-sm: clamp(1rem, 2vw, 1.5rem);
  --spacing-md: clamp(1.5rem, 3vw, 2rem);
  --spacing-lg: clamp(2rem, 4vw, 3rem);
  --animation-speed-slow: 4s;
  --animation-speed-medium: 2s;
  --animation-speed-fast: 1s;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--night-sky) 0%, #16213e 100%);
  font-family: 'Arial', sans-serif;
  overflow-x: hidden;
}

.christmas-theme {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--spacing-md);
  box-sizing: border-box;
}

.content {
  width: min(90%, 1200px);
  margin: 0 auto;
  text-align: center;
  z-index: 3;
  padding: var(--spacing-md);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  backdrop-filter: blur(5px);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

/* Animations */
@keyframes fall {
  0% {
    transform: translateY(-10vh) rotate(0deg);
  }

  100% {
    transform: translateY(100vh) rotate(360deg);
  }
}

@keyframes twinkle {
  0% {
    opacity: 0.4;
    transform: scale(0.8);
  }

  50% {
    opacity: 1;
    transform: scale(1.1);
  }

  100% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

@keyframes glow {
  0% {
    text-shadow: var(--text-shadow);
    filter: brightness(1);
  }

  50% {
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    filter: brightness(1.2);
  }

  100% {
    text-shadow: var(--text-shadow);
    filter: brightness(1);
  }
}

@keyframes float {
  0% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-10px) rotate(5deg);
  }

  100% {
    transform: translateY(0) rotate(0deg);
  }
}

@keyframes starTwinkle {
  0% {
    transform: scale(1) rotate(0deg);
    filter: brightness(1);
  }

  50% {
    transform: scale(1.2) rotate(20deg);
    filter: brightness(1.3);
  }

  100% {
    transform: scale(1) rotate(0deg);
    filter: brightness(1);
  }
}

@keyframes lightUp {
  0% {
    opacity: 0.3;
    filter: brightness(0.8);
  }

  50% {
    opacity: 1;
    filter: brightness(1.2);
  }

  100% {
    opacity: 0.3;
    filter: brightness(0.8);
  }
}

/* Components */
.santa {
  position: fixed;
  top: clamp(20px, 5vh, 50px);
  font-size: clamp(40px, 8vw, 60px);
  z-index: 4;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
  transform: scaleX(-1);
  transition: transform 0.3s ease;
}

.santa:hover {
  transform: scaleX(-1) translateY(-10px);
}

.snowflake {
  position: fixed;
  color: var(--snow-white);
  font-size: clamp(10px, 2vw, 20px);
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
  animation: fall linear forwards;
  z-index: 1;
}

.header {
  margin-bottom: var(--spacing-lg);
  position: relative;
}

.title {
  font-size: var(--font-size-xl);
  color: var(--gold);
  text-shadow: var(--text-shadow);
  margin-bottom: var(--spacing-sm);
  animation: glow var(--animation-speed-medium) infinite;
  font-family: 'Arial Rounded MT Bold', 'Arial', sans-serif;
  letter-spacing: 2px;
}

.subtitle {
  font-size: var(--font-size-lg);
  color: var(--snow-white);
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
  font-style: italic;
}

.scene {
  position: relative;
  margin: var(--spacing-lg) auto;
  min-height: clamp(300px, 50vh, 400px);
  transition: transform 0.3s ease;
  perspective: 1000px;
}

.moon {
  position: absolute;
  top: -20px;
  right: clamp(20px, 5%, 50px);
  font-size: clamp(40px, 8vw, 60px);
  animation: float var(--animation-speed-slow) infinite;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

.tree {
  position: relative;
  margin: var(--spacing-lg) auto;
  text-align: center;
  transform-style: preserve-3d;
}

.star {
  font-size: clamp(30px, 6vw, 40px);
  animation: starTwinkle var(--animation-speed-medium) infinite;
  position: relative;
  z-index: 2;
}

.branch {
  font-size: clamp(20px, 4vw, 30px);
  line-height: 1.2;
  transform-origin: center bottom;
  animation: float 3s infinite;
  position: relative;
}

.branch:hover {
  transform: scale(1.1);
  filter: brightness(1.2);
}

.trunk {
  font-size: clamp(30px, 6vw, 40px);
  margin-top: var(--spacing-xs);
}

.decorations {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  pointer-events: none;
  z-index: 3;
}

.candy-cane,
.bell,
.holly {
  position: absolute;
  font-size: clamp(20px, 4vw, 30px);
  animation: float var(--animation-speed-medium) infinite;
}

.candy-cane {
  left: 20%;
  top: 30%;
}

.bell {
  right: 25%;
  top: 45%;
  animation-delay: 0.5s;
}

.holly {
  left: 30%;
  bottom: 25%;
  animation-delay: 1s;
}

.controls {
  margin-top: var(--spacing-lg);
  position: relative;
  z-index: 5;
}

.music-toggle {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-md);
  background: linear-gradient(145deg, var(--christmas-red), #ff3336);
  color: var(--snow-white);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(212, 36, 38, 0.3);
  font-weight: bold;
  letter-spacing: 1px;
}

.music-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(212, 36, 38, 0.4);
  background: linear-gradient(145deg, #ff3336, var(--christmas-red));
}

.music-toggle:active {
  transform: translateY(1px);
  box-shadow: 0 2px 10px rgba(212, 36, 38, 0.3);
}

.snowfall-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.lights-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-around;
  padding: var(--spacing-sm);
  z-index: 3;
}

.light {
  position: absolute;
  font-size: 20px;
  animation: lightUp 2s infinite;
}

@media (max-width: 480px) {
  .music-toggle {
    width: 100%;
    max-width: 300px;
    font-size: var(--font-size-sm);
  }

  .decorations {
    transform: scale(0.8);
  }

  .lights-container {
    display: none;
  }

  .scene {
    transform: scale(0.7);
    margin: var(--spacing-md) auto;
  }

  .title {
    font-size: var(--font-size-lg);
  }

  .subtitle {
    font-size: var(--font-size-md);
  }
}
              
            
!

JS

              
                // Snowfall
function createSnowflake() {
  const snowflake = document.createElement('div');
  snowflake.classList.add('snowflake');
  snowflake.style.left = Math.random() * 100 + 'vw';
  snowflake.style.animationDuration = Math.random() * 3 + 2 + 's';
  snowflake.style.opacity = Math.random();
  snowflake.innerHTML = '❄';
  return snowflake;
}

function initSnowfall() {
  const container = document.querySelector('.snowfall-container');
  setInterval(() => {
    const snowflake = createSnowflake();
    container.appendChild(snowflake);
    setTimeout(() => {
      snowflake.remove();
    }, 5000);
  }, 200);
}

// Lights
function initLights() {
  const container = document.querySelector('.lights-container');
  const colors = ['🔴', '🟡', '🟢', '🔵'];

  for (let i = 0; i < 20; i++) {
    const light = document.createElement('div');
    light.classList.add('light');
    light.textContent = colors[i % colors.length];
    light.style.animationDelay = `${i * 0.1}s`;
    light.style.left = `${(i / 20) * 100}%`;
    container.appendChild(light);
  }
}

// Santa
function initSanta() {
  const santa = document.querySelector('.santa');
  let position = -150;

  function moveSanta() {
    position += 1;
    santa.style.left = `${position}px`;

    if (position > window.innerWidth + 150) {
      position = -150;
    }

    requestAnimationFrame(moveSanta);
  }

  moveSanta();
}

// Music
const musicToggle = document.querySelector('.music-toggle');
const audio = new Audio('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3');
audio.loop = true;

musicToggle.addEventListener('click', () => {
  if (audio.paused) {
    audio.play();
    musicToggle.textContent = '🔇 Stop Carols';
  } else {
    audio.pause();
    musicToggle.textContent = '🎵 Christmas Carols';
  }
});

// Initialize
initSnowfall();
initLights();
initSanta();
              
            
!
999px

Console