Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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="warning">
  <p>⚠️ Your browser does not support CSS Scroll-Linked Animations, so this demo won't work. If you're feeling adventurous use Chrome 89 with “Experimental Web Platform Features” enabled.</p>
</div>
<nav>
  <ul>
    <li><a href="#section_1">Section 1</a></li>
    <li><a href="#section_2">Section 2</a></li>
    <li><a href="#section_3">Section 3</a></li>
    <li><a href="#section_4">Section 4</a></li>
  </ul>
</nav>
<main id="main">
  <aside class="stuck">
    <h1>
      <span invisible>x</span>
      <span class="slash">/</span>
      <span> 4</span>
    </h1>
  </aside>
  <section id="section_1">
    <h1>
      <span>1</span>
      <span invisible class="slash">/</span>
      <span invisible>4</span>
    </h1>
  </section>
  <section id="section_2">
    <h1>
      <span>2</span>
      <span invisible class="slash">/</span>
      <span invisible>4</span>
    </h1>
    </div>
  </section>
  <section id="section_3">
    <h1>
      <span>3</span>
      <span invisible class="slash">/</span>
      <span invisible>4</span>
    </h1>
    </div>
  </section>
  <section id="section_4">
    <h1>
      <span>4</span>
      <span invisible class="slash">/</span>
      <span invisible>4</span>
    </h1>
    </div>
  </section>
</main>
              
            
!

CSS

              
                /*

Forked from https://codepen.io/argyleink/pen/XWdNYaY by @argyleink

Adjustments:
- Uses mix-blend-mode instead of clip, resulting in a lighter markup
- Added a navigation with active indicator

Also see https://codepen.io/bramus/pen/yLaZJOp that has one sliding active indicator

*/

@supports (animation-timeline: works) {
  
  @scroll-timeline scroll-sections {
    source: selector(#main);  
    time-range: 4s;
  }
  
  @scroll-timeline scroll-sections-first-item {
    source: selector(#main);
    start: 0;
    end: 33.333333333%;
    scroll-offsets: 0, 33.333333333%;
    time-range: 2s;
  }
  
  @scroll-timeline scroll-sections-second-item {
    source: selector(#main);
    start: 0;
    end: 66.6666666666%;
    scroll-offsets: 0, 66.6666666666%;
    time-range: 4s;
  }
  
  @scroll-timeline scroll-sections-third-item {
    source: selector(#main);  
    start: 33.333333333%;
    end: 100%; 
    scroll-offsets: 33.333333333%, 100%;
    time-range: 4s;
  }
  
  @scroll-timeline scroll-sections-fourth-item {
    source: selector(#main);  
    start: 66.6666666666%;
    end: 100%;
    scroll-offsets: 66.6666666666%, 100%;
    time-range: 2s;
  }

  @keyframes rotato {
    to {
      transform: rotateZ(3turn);
    }
  }

  .slash {
    animation: rotato 4s linear;
    animation-timeline: scroll-sections;
  }

  @keyframes reveal-indicator {
    1% { /* We use 1% instead of 0% to prevent rouding/rendering glitches */
      transform: scaleX(0);
    }
    50% {
      transform: scaleX(1);
    }
    99% {  /* We use 99% instead of 100% to prevent rouding/rendering glitches */
      transform: scaleX(0);
    }
  }
  
  nav li {
    position: relative;
  }

  nav li::after {
    content: '';
    height: 3px;
    width: 100%;
    left: 0;
    bottom: -0.3em;
    position: absolute;
    background: #fff;
    transform: scaleX(0);
    animation: 4s linear reveal-indicator;
  }
  
  nav li:nth-child(1)::after {
    animation-timeline: scroll-sections-first-item;
    animation-delay: -2s;
  }
  
  nav li:nth-child(2)::after {
    animation-timeline: scroll-sections-second-item;
  }
  
  nav li:nth-child(3)::after {
    animation-timeline: scroll-sections-third-item;
  }
  
  nav li:nth-child(4)::after {
    animation-timeline: scroll-sections-fourth-item;
  }
  
  .warning {
    display: none;
  }

}

main {
  max-block-size: 100vh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

section {
  block-size: 100vh;
  inline-size: 100vw;
  scroll-snap-align: start;
  display: grid;
  place-content: center;
  position: relative;
}

section:nth-of-type(odd) {
  background: black;
  color: white;
}

h1 {
  font-variant-numeric: tabular-nums;
  font-size: 25vmin;
  font-weight: 300;
  display: flex;
  align-items: center;
  flex-gap: 0.5ch;
}

.slash {
  font-family: Roboto, monospace;
}

.stuck {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  pointer-events: none;
  color: #fff;
  mix-blend-mode: difference;
} 

.stuck > h1 {
  position: fixed;
  z-index: 1;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  will-change: transform;
  place-content: center;
  grid-auto-flow: column;
}

[invisible] {
  visibility: hidden;
}

nav {
  position: fixed;
  z-index: 10;
  mix-blend-mode: difference;
  width: 100vw;
  display: flex;
  place-items: center;
  font-size: 4vmin;
  margin-top: 1.5em;
}

nav ul {
  list-style: none;
  text-align: center;
  margin: 0 auto;
  padding: 0;
  display: flex;
  position: relative;
}

nav li {
  display: inline-block;
  white-space: nowrap;
}

nav a {
  color: #fff;
  text-decoration: none;
  display: inline-block;
  padding: 0.5em;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: #fff;
}

body {
  box-sizing: border-box;
  font-family: system-ui, sans-serif;
}

main {
  font-weight: 400;
}

.warning {
  position: fixed;
  bottom: 1em;
  right: 1em;
  left: 1em;
	padding: 1em;
	border: 1px solid #fff;
  z-index: 1;
  text-align: center;
  color: #fff;
  mix-blend-mode: difference;
}

.warning p {
	margin: 0;
	padding: 0;
}

              
            
!

JS

              
                
              
            
!
999px

Console