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

              
                  <figure>
    <img src="https://picsum.photos/1920/768?random=1" alt="" class="b">
    <figcaption>Decorate tree</figcaption>
  </figure>
  <ul class="thumbnails">
    <li><img class="thumbnail" src="https://picsum.photos/1920/768?random=1" alt="Decorate tree" style="--index: 0;"></li>
    <li><img class="thumbnail" src="https://picsum.photos/1920/768?random=2" alt="Buy gifts" style="--index: 1;"></li>
    <li><img class="thumbnail" src="https://picsum.photos/1920/768?random=3" alt="Set up lights" style="--index:2 ;"></li>
    <li><img class="thumbnail" src="https://picsum.photos/1920/768?random=4" alt="Wrap presents" style="--index: 3;"></li>
    <li><img class="thumbnail" src="https://picsum.photos/1920/768?random=5" alt="Cookies milk" style="--index: 4;"></li>
    <li><img class="thumbnail" src="https://picsum.photos/1920/768?random=6" alt="Moonbyul" style="--index: 5;"></li>
    <li><img class="thumbnail" src="https://picsum.photos/1920/768?random=7" alt="Solar" style="--index: 6;"></li>
    <li><img class="thumbnail" src="https://picsum.photos/1920/768?random=8" alt="Wheein" style="--index: 7;"></li>
    <li><img class="thumbnail" src="https://picsum.photos/1920/768?random=9" alt="Hwasa" style="--index: 8;"></li>
    <li><img class="thumbnail" src="https://picsum.photos/1920/768?random=10" alt="Holiday To Do List" style="--index: 9;"></li>
  </ul>

<div class="tutorials">
  <a href="https://s.juejin.cn/ds/idkRes2Y/" target="_blank">
    <svg t="1696988571607" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4422" width="200" height="200"><path d="M924.8 576.64v-115.2c12.8-13.44 13.44-26.88 12.8-34.56-3.2-30.08-36.48-42.24-47.36-46.72-79.36-30.08-226.56-89.6-307.84-122.88-49.28-24.32-65.28-19.84-113.28-0.64-12.8 5.12-224.64 83.84-306.56 117.76-44.8 18.56-51.2 46.08-51.2 61.44 0 25.6 17.92 48.64 50.56 62.08L259.84 537.6v257.28l8.32 8.32c3.84 3.84 91.52 92.16 252.16 92.16 150.4 0 236.16-88.96 240-92.8l7.68-8.32V540.16l36.48-15.36-1.28 52.48-29.44 49.28 88.96 84.48 98.56-85.76-36.48-48.64zM710.4 771.2c-22.4 18.56-88.96 67.2-190.08 67.2-111.36 0-179.84-48.64-202.88-67.2V561.28l144.64 58.88h0.64c46.08 17.28 81.28 16 125.44-3.2l122.24-51.84v206.08z m154.24-138.24l-17.92-16.64 13.44-22.4 2.56-102.4c4.48-14.08-0.64-25.6-8.32-32-7.68-7.04-21.76-11.52-36.48-2.56L565.12 563.84c-30.08 13.44-49.92 14.08-81.92 2.56l-298.88-121.6c-7.68-3.2-12.16-6.4-14.08-8.96 1.92-1.92 6.4-5.12 14.72-8.96 81.92-33.92 302.72-116.48 305.28-117.12h0.64c38.4-15.36 38.4-15.36 67.2-0.64l1.92 0.64c80.64 32.64 226.56 92.16 307.2 122.88v163.2l16 21.12-18.56 16z" p-id="4423"></path></svg>
  </a>
  
</div>
              
            
!

CSS

              
                @layer reset, base, layout, transitions;

@layer transitions {
  :root {
    --originPosUnit: 25%;
  }

  @keyframes grow {
    from {
      scale: 0;
    }
    to {
      scale: 1;
    }
  }

  figure {
    view-transition-name: figure;
  }
  figcaption {
    view-transition-name: figureCaption;
  }

  ::view-transition-old(figure),
  ::view-transition-new(figure) {
    transform-origin: 100% var(--originPosUnit);
  }

  ::view-transition-new(figure) {
    animation: 400ms ease-out both grow;
  }
}

@layer layout {
  figure {
    position: relative;
    margin: 4px;

    & img {
      position: absolute;
      inset: 0;
    }

    & figcaption {
      position: absolute;
      top: 50%;
      left: 50%;
      translate: -50% -50%;
      font-size: clamp(3rem, 4vw + 3.25rem, 4rem);
      white-space: nowrap;
      background-image: radial-gradient(
        farthest-corner circle at 0% 0% in oklch,
        oklch(100% 0.25 160) 0%,
        26%,
        oklch(75% 0.5 180) 0% 0%,
        46%,
        oklch(75% 0.5 210) 0% 0%,
        60%,
        oklch(75% 0.5 230) 0% 0%,
        82%,
        oklch(75% 0.5 260) 0% 0%
      );
      background-clip: text;
      -webkit-background-clip: text;
      -webkit-text-stroke: 2px #000;
      color: transparent;
      mix-blend-mode: difference;
      text-transform: uppercase;
      letter-spacing: 2px;
      font-weight: 900;
      font-family: "Josefin Sans";
      text-shadow: 1px 1px 0 color-mix(in oklch, #fff, transparent 10%),
        2px 2px 0 color-mix(in oklch, #fff, transparent 20%),
        3px 3px 0 color-mix(in oklch, #fff, transparent 30%),
        4px 4px 0 color-mix(in oklch, #fff, transparent 40%),
        5px 5px 0 color-mix(in oklch, #fff, transparent 50%),
        6px 6px 0 color-mix(in oklch, #fff, transparent 60%),
        7px 7px 0 color-mix(in oklch, #fff, transparent 70%),
        8px 8px 0 color-mix(in oklch, #fff, transparent 80%),
        9px 9px 0 color-mix(in oklch, #fff, transparent 80%);
    }
  }

  .thumbnails {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;

    & li {
      aspect-ratio: 4 / 3;
    }
  }
}

@layer reset {
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  ul {
    list-style: none outside none;
  }

  img {
    display: block;
    object-fit: cover;
    object-position: center;
    width: 100%;
    height: 100%;
  }
}

@layer base {
  body {
    width: 100vw;
    min-height: 100vh;
    font-family: "Exo", "Bungee Shade", cursive, Arial, sans-serif;
    background-color: #110d14;
    color: #fff;
    display: grid;
    place-content: start center;
    grid-template-rows: minmax(0, 1fr) auto;
  }
  @media (prefers-reduced-motion: reduce) {
    *,
    ::before,
    ::after {
      animation-delay: -1ms !important;
      animation-duration: 1ms !important;
      animation-iteration-count: 1 !important;
      background-attachment: initial !important;
      scroll-behavior: auto !important;
      transition-duration: 0s !important;
      transition-delay: 0s !important;
    }
  }
  .tutorials {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
    width: 64px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: #3f517e;
    padding: .5rem;
    display: grid;
    place-content: center;
    transition: all .28s linear;
    
    &:hover {
      background:#4161b2;
    }
    
    & svg {
      display: block;
      width: 100%;
      height: 100%;
      filter: invert(1);
    }
  }
}

              
            
!

JS

              
                const thumbnails = document.querySelector(".thumbnails");
const mainImage = document.querySelector("figure img");
const imageHeading = document.querySelector("figcaption");

const thumbnailHandler = (event) => {
  const clickTarget = event.target;
  
  const displayNewImage = () => {
    mainImage.src = clickTarget.src;
    imageHeading.textContent = clickTarget.alt;
    document.documentElement.style.setProperty(
      "--originPosUnit",
      `${getComputedStyle(clickTarget).getPropertyValue("--index") * 25 + 12.5}%`
    );
  };

  if (clickTarget.classList.contains("thumbnail")) {
    if (!document.startViewTransition) {
      displayNewImage();
      return;
    }
 
    const transition = document.startViewTransition(() => displayNewImage());
  }
};

thumbnails.addEventListener("click", thumbnailHandler, false);
              
            
!
999px

Console