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 class="pagination">
  <a href="#section-1">Inline page 1</a>
  <a href="#section-2">Inline page 2</a>
  <a href="#section-3">Inline page 3</a>
  <a href="#section-4">Inline page 4</a>
  <a href="#section-5">Inline page 5</a>
  <a href="#section-6">Inline page 6</a>
  <a href="#section-7">Inline page 7</a>
</div>

<div class="controls">
  <button class="previous" onclick="window.scrollBy(-100, 0)">
    <svg viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
      <path d="M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18" />
    </svg>
  </button>
  <button class="next" onclick="window.scrollBy(100, 0)">
    <svg viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
      <path d="M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3" />
    </svg>
  </button>
</div>

<section id="section-1">
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Whoa.svg" height="500" width="500">
    </picture>
    <h5>Lorem ipsum dolor sit amet</h5>
    <p>Ut enim ad minim veniam, quis nostrud.</p>
    <a href="https://www.transhumans.xyz">Check it out</a>
  </article>
  
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Walking+Contradiction.svg" height="500" width="500">
    </picture>
    <h5>Consectetur adipiscing elit</h5>
    <p>Exercitation ullamco laboris nisi ut aliquip ex ea commodo.</p>
    <a href="https://www.transhumans.xyz">Some action</a>
  </article>
  
  <article class="card">
    <picture>
      <img class="card-img" src="https://assets.codepen.io/2585/Polka+Pup.svg" alt="placeholder-hand-drawn-vector" height="500" width="500">
    </picture>
    <h5>Sed do eiusmod tempor incididunt</h5>
    <p>Duis aute irure dolor in reprehenderit.</p>
    <a href="https://www.transhumans.xyz">Ready</a>
  </article>
</section>
<section id="section-2">
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Pilot.svg" height="500" width="500">
    </picture>
    <h5>Lorem ipsum dolor sit amet</h5>
    <p>Ut enim ad minim veniam, quis nostrud.</p>
    <a href="https://www.transhumans.xyz">Check it out</a>
  </article>
  
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Cube+Leg.svg" height="500" width="500">
    </picture>
    <h5>Consectetur adipiscing elit</h5>
    <p>Exercitation ullamco laboris nisi ut aliquip ex ea commodo.</p>
    <a href="https://www.transhumans.xyz">Some action</a>
  </article>
  
  <article class="card">
    <picture>
      <img class="card-img" src="https://assets.codepen.io/2585/Growth.svg" alt="placeholder-hand-drawn-vector" height="500" width="500">
    </picture>
    <h5>Sed do eiusmod tempor incididunt</h5>
    <p>Duis aute irure dolor in reprehenderit.</p>
    <a href="https://www.transhumans.xyz">Ready</a>
  </article>
</section>
<section id="section-3">
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Gamestation.svg" height="500" width="500">
    </picture>
    <h5>Lorem ipsum dolor sit amet</h5>
    <p>Ut enim ad minim veniam, quis nostrud.</p>
    <a href="https://www.transhumans.xyz">Check it out</a>
  </article>
  
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Kiddo.svg" height="500" width="500">
    </picture>
    <h5>Consectetur adipiscing elit</h5>
    <p>Exercitation ullamco laboris nisi ut aliquip ex ea commodo.</p>
    <a href="https://www.transhumans.xyz">Some action</a>
  </article>
  
  <article class="card">
    <picture>
      <img class="card-img" src="https://assets.codepen.io/2585/Reflecting.svg" alt="placeholder-hand-drawn-vector" height="500" width="500">
    </picture>
    <h5>Sed do eiusmod tempor incididunt</h5>
    <p>Duis aute irure dolor in reprehenderit.</p>
    <a href="https://www.transhumans.xyz">Ready</a>
  </article>
</section>
<section id="section-4">
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Rogue.svg" height="500" width="500">
    </picture>
    <h5>Lorem ipsum dolor sit amet</h5>
    <p>Ut enim ad minim veniam, quis nostrud.</p>
    <a href="https://www.transhumans.xyz">Check it out</a>
  </article>
  
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Waiting.svg" height="500" width="500">
    </picture>
    <h5>Consectetur adipiscing elit</h5>
    <p>Exercitation ullamco laboris nisi ut aliquip ex ea commodo.</p>
    <a href="https://www.transhumans.xyz">Some action</a>
  </article>
  
  <article class="card">
    <picture>
      <img class="card-img" src="https://assets.codepen.io/2585/Runner.svg" alt="placeholder-hand-drawn-vector" height="500" width="500">
    </picture>
    <h5>Sed do eiusmod tempor incididunt</h5>
    <p>Duis aute irure dolor in reprehenderit.</p>
    <a href="https://www.transhumans.xyz">Ready</a>
  </article>
</section>
<section id="section-5">
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Plants.svg" height="500" width="500">
    </picture>
    <h5>Lorem ipsum dolor sit amet</h5>
    <p>Ut enim ad minim veniam, quis nostrud.</p> 
    <a href="https://www.transhumans.xyz">Check it out</a>
  </article>
  
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Coffee.svg" height="500" width="500">
    </picture>
    <h5>Consectetur adipiscing elit</h5>
    <p>Exercitation ullamco laboris nisi ut aliquip ex ea commodo.</p>
    <a href="https://www.transhumans.xyz">Some action</a>
  </article>
  
  <article class="card">
    <picture>
      <img class="card-img" src="https://assets.codepen.io/2585/Chaotic+Good.svg" alt="placeholder-hand-drawn-vector" height="500" width="500">
    </picture>
    <h5>Sed do eiusmod tempor incididunt</h5>
    <p>Duis aute irure dolor in reprehenderit.</p>
    <a href="https://www.transhumans.xyz">Ready</a>
  </article>
</section>
<section id="section-6">
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Jumping.svg" height="500" width="500">
    </picture>
    <h5>Lorem ipsum dolor sit amet</h5>
    <p>Ut enim ad minim veniam, quis nostrud.</p>
    <a href="https://www.transhumans.xyz">Check it out</a>
  </article>
  
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Whoa.svg" height="500" width="500">
    </picture>
    <h5>Consectetur adipiscing elit</h5>
    <p>Exercitation ullamco laboris nisi ut aliquip ex ea commodo.</p>
    <a href="https://www.transhumans.xyz">Some action</a>
  </article>
  
  <article class="card">
    <picture>
      <img class="card-img" src="https://assets.codepen.io/2585/Pacheco.svg" alt="placeholder-hand-drawn-vector" height="500" width="500">
    </picture>
    <h5>Sed do eiusmod tempor incididunt</h5>
    <p>Duis aute irure dolor in reprehenderit.</p>
    <a href="https://www.transhumans.xyz">Ready</a>
  </article>
</section>
<section id="section-7">
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Meela+Pantalones.svg" height="500" width="500">
    </picture>
    <h5>Lorem ipsum dolor sit amet</h5>
    <p>Ut enim ad minim veniam, quis nostrud.</p>
    <a href="https://www.transhumans.xyz">Check it out</a>
  </article>
  
  <article class="card">
    <picture>
      <img src="https://assets.codepen.io/2585/Groceries.svg" height="500" width="500">
    </picture>
    <h5>Consectetur adipiscing elit</h5>
    <p>Exercitation ullamco laboris nisi ut aliquip ex ea commodo.</p>
    <a href="https://www.transhumans.xyz">Some action</a>
  </article>
  
  <article class="card">
    <picture>
      <img class="card-img" src="https://assets.codepen.io/2585/Fling.svg" alt="placeholder-hand-drawn-vector" height="500" width="500">
    </picture>
    <h5>Sed do eiusmod tempor incididunt</h5>
    <p>Duis aute irure dolor in reprehenderit.</p>
    <a href="https://www.transhumans.xyz">Ready</a>
  </article>
</section>
              
            
!

CSS

              
                @import "https://unpkg.com/open-props" layer(design.system);
@import "https://unpkg.com/open-props/normalize.min.css" layer(demo.support);
@import "https://unpkg.com/open-props/buttons.min.css" layer(demo.support);

/* Getting Started:
   Collapse each @layer.
   Dig into color or the scroll animation code.
*/

@layer demo.color {
  /* type safe angle prop for use with SDA */
  @property --hue {
    syntax: '<angle>';
    initial-value: 0turn;
    inherits: false;
  }

  /* will animate the angle prop 1 full turn */
  @keyframes hue-cycle { to {
    --hue: 1turn;
  }}
  
  :root {
    /* dynamic color props, hue powered by scroll */
    /* with oklch, keep lightness (L) ~50-60% different between surface and text, for good contrast across hues */
    --surface-1: oklch(40% 50% var(--hue));
    --surface-2: oklch(50% 40% var(--hue));
    --text-1: oklch(98% 10% var(--hue));
    --text-2: oklch(95% 20% var(--hue));
    --link: oklch(99% 10% var(--hue));
    --link-visited: oklch(90% 40% var(--hue));
    --focus: oklch(80% 90% var(--hue));

    /* fallback for if @property isnt supported */
    --hue: 275;
    
    background: radial-gradient(farthest-corner circle at bottom center in oklab, 
      oklch(from var(--surface-2) calc(l * 1.25) c h),
      var(--surface-1)
    ) fixed no-repeat;
  }
  
  /* this section uses those dynamic color props on elements */
  :focus-visible {
    outline-color: var(--focus);
  }
  
  .card {
    background: var(--surface-2);
  }

  h1, h2, h3, h4, h5, h6 {
    color: var(--text-1);
  }

  p {
    color: var(--text-2);
  }
  
  button {
    --_bg: var(--surface-2);
    --_border: var(--surface-1);
    --_highlight: color-mix(in oklab, var(--text-2), transparent 75%);
    box-shadow: 0 0 0 var(--_highlight-size) var(--_highlight);
    padding: var(--size-2);
    border-radius: var(--radius-round);
    aspect-ratio: var(--ratio-box);
    transition: box-shadow 145ms var(--ease-4), outline-offset 145ms var(--ease-4);
  }
  
  .pagination > a {
    background: var(--surface-2);
  }
  
  a {
    text-decoration-color: var(--focus);
  }
}

@layer demo.scroll-driven-animation {
  :root {
    overflow-x: auto;
    overscroll-behavior: contain;
    
    /* be a snap scroller on x */
    scroll-snap-type: x mandatory;
    
    /* scroll snap sections */
    & body > section {
      scroll-snap-align: start;
    }
    
    @supports (animation-timeline: scroll()) {
      /* animate the --hue prop using the keyframes */
      animation: hue-cycle linear both;

      /* animation progress is the full page scroll range */
      animation-timeline: scroll(x); 
    }
  }
  
  /* pagination dots effect */
  /* scaled out, until in view, then scale 1 */
  @keyframes dot-selected { 
    0%, 100% {
      scale: .75;
    }
    50% {
      scale: 1;
      background: var(--text-2);
    }
  }

  /* expose the following view timelines for any elements to observe by name */
  body {
    timeline-scope: 
      --section-1, 
      --section-2, 
      --section-3, 
      --section-4, 
      --section-5, 
      --section-6, 
      --section-7
    ;
  }

  /* give each section it's relevant view timeline name */
  /* note: this must match the name exposed on the body timeline-scope */
  #section-1 { view-timeline: --section-1 x }
  #section-2 { view-timeline: --section-2 x }
  #section-3 { view-timeline: --section-3 x }
  #section-4 { view-timeline: --section-4 x }
  #section-5 { view-timeline: --section-5 x }
  #section-6 { view-timeline: --section-6 x }
  #section-7 { view-timeline: --section-7 x }

  .pagination > a {
    @supports (animation-timeline: scroll()) {
      animation: dot-selected linear both;  
    }

    /* power the scale animation by observing a relevant view timeline */
    &:nth-child(1) { animation-timeline: --section-1 }
    &:nth-child(2) { animation-timeline: --section-2 }
    &:nth-child(3) { animation-timeline: --section-3 }
    &:nth-child(4) { animation-timeline: --section-4 }
    &:nth-child(5) { animation-timeline: --section-5 }
    &:nth-child(6) { animation-timeline: --section-6 }
    &:nth-child(7) { animation-timeline: --section-7 }
  }
  
  /* card entry/exit animations */
  @keyframes fancy-in {
    0% {
      transform: translateX(25vw);
    }
    20%, 80% {
      opacity: 1;
      transform: none;
    }
    100% {
      transform: translateX(90%) scale(.98);
      opacity: 0;
    }
  }
  
  .card {
    @media (prefers-reduced-motion: no-preference) {
      @supports (animation-timeline: scroll()) {
        animation: fancy-in linear both;
        animation-timeline: view(x);
      }
    }
  }
  
  /* fade in/out of the next/previous buttons */
  @keyframes toggle-control {
    50% { 
      opacity: 0 
    }
  }

  .controls {
    & > button {
      /* if supported, enable the visibility toggling animation */
      @supports (animation-timeline: scroll()) {
        animation: toggle-control linear both;
      }

      /* fade out the previous button when section 1 is in view */
      &.previous {
        animation-timeline: --section-1;
      }

      /* fade out the next button when at the last section */
      &.next {
        animation-timeline: --section-7;
      }
    }
  }
}

@layer demo.support {
  body {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 100vw;
  }
  
  .pagination {
    position: fixed;
    z-index: 1;
    inset-inline: 0;
    inset-block-end: var(--size-5);
    display: flex;
    place-content: center;
    gap: var(--size-3);
    padding: var(--size-3);
    
    & > a {
      display: inline-flex;
      place-content: center;
      inline-size: 2ch;
      flex-shrink: 0;
      aspect-ratio: var(--ratio-square);
      border-radius: var(--radius-round);
      overflow: hidden;
      text-indent: 100vw;
      
      &:is(:hover, :focus-visible) {
        outline: 1px dashed var(--focus);
        outline-offset: 2px;
      }
      
      &:visited {
        background: inherit !important;
      }
    }
  }
  
  .controls {
    position: fixed;
    z-index: 1;
    inset-block-start: calc(50% - var(--size-5) / 2);
    inset-inline: var(--size-3);
    display: flex;
    justify-content: space-between;
  }
  
  section {
    display: grid;
    place-content: center;
    grid-template-columns: repeat(auto-fit, minmax(20ch, min(30ch, 25cqi)));
    gap: var(--size-5);
    padding: var(--size-5);
    
    & > * {
      display: grid;
      grid-row: span 4; 
      grid-template-rows: subgrid; 
      gap: var(--size-2);
    }
  }
  
  .card {
    border: 1px solid transparent;
    padding-block: var(--size-5);
    padding-inline: var(--size-7);
    border-radius: var(--radius-3);
    
    & > a {
      white-space: nowrap;
      justify-self: start;
    }
    
    @media (prefers-reduced-motion: no-preference) {
      transition: transform .5s var(--ease-spring-3);
      
      &:focus-within {
        transform: translateY(-10px);
      }
    }
  }
  
  article > img {
    opacity: .75;
  }
}
              
            
!

JS

              
                            
              
            
!
999px

Console