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

              
                <nav>jbrand</nav>
    <main>
      <article style="--index: 0;">
        <div class="article__img">
          <img src="https://picsum.photos/1920/1080?random=1" alt="">
        </div>
        <div class="article__info">
          <h2>CSS Scroll Animations</h2>
          <p>Check out this rad demo</p>
          <a href="#">Preorder</a>
        </div>
      </article>
      <article style="--index: 1;">
        <div class="article__img">
          <img src="https://picsum.photos/1920/1080?random=2" alt="">
        </div>
        <div class="article__info">
          <h2>Animate on scroll</h2>
          <p>Works with media queries too</p>
          <a href="#">Check it out</a>
        </div>
      </article>
      <article style="--index: 2;">
        <div class="article__img">
          <img src="https://picsum.photos/1920/1080?random=3" alt="">
        </div>
        <div class="article__info">
          <h2>Parallax Effects</h2>
          <p>Tweak your timings</p>
          <a href="#">Get Styling</a>
        </div>
      </article>
      <article style="--index: 3;">
        <div class="article__img">
          <img src="https://picsum.photos/1920/1080?random=4" alt="">
        </div>
        <div class="article__info">
          <h2>Drive Keyframes</h2>
          <p>CSS alone and...</p>
          <a href="#">No JavaScript</a>
        </div>
      </article>
      <article style="--index: 4;">
        <div class="article__img">
          <img src="https://picsum.photos/1920/1080?random=5" alt="">
        </div>
        <div class="article__info">
          <h2>Extra Slides</h2>
          <p>More content because...</p>
          <a href="#">CSS to the moon</a>
        </div>
      </article>
      <article style="--index: 5;">
        <div class="article__img">
          <img src="https://picsum.photos/1920/1080?random=6" alt="">
        </div>
        <div class="article__info">
          <h2>Resize Window</h2>
          <p>Try resizing the window</p>
          <a href="#">Resize</a>
        </div>
      </article>
      <article style="--index: 6;">
        <div class="article__img">
          <img src="https://picsum.photos/1920/1080?random=7" alt="">
        </div>
        <div class="article__info">
          <h2>Browser support</h2>
          <p>You'll need to be in Chrome Canary</p>
          <a href="#">Do it</a>
        </div>
      </article>
      <article style="--index: 7;">
        <div class="article__img">
          <img src="https://picsum.photos/1920/1080?random=8" alt="">
        </div>
        <div class="article__info">
          <h2>Your idea</h2>
          <p>What would you make?</p>
          <a href="#">Code</a>
        </div>
      </article>
      <article style="--index: 8;">
        <div class="article__img">
          <img src="https://picsum.photos/1920/1080?random=9" alt="">
        </div>
        <div class="article__info">
          <h2>Fork</h2>
          <p>Fork this and make it your own!</p>
          <a href="#">Duplicate</a>
        </div>
      </article>
      <article style="--index: 9;">
        <div class="article__img">
          <img src="https://picsum.photos/1920/1080?random=10" alt="">
        </div>
        <div class="article__info">
          <h2>Heart</h2>
          <p>If you like this, heart it (3x)</p>
          <a href="#">Like</a>
        </div>
      </article>
    </main>
              
            
!

CSS

              
                *,
*:after,
*:before {
	box-sizing: border-box;	
}

:root {
	--info-size: 35vh;
}

body {
	display: grid;
	place-items: center;
	min-height: 100vh;
	font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
	overflow: auto;
}

nav {
	position: sticky;
	top: 0;
	left: 0;
	width: 100%;
	height: 80px;
	text-align: left;
	font-weight: bold;
	font-size: 1.75rem;
	display: flex;
	align-items: center;
	background: hsl(0 0% 0%);
	color: hsl(0 0% 98%);
	padding: 0 1rem;
	z-index: 3;
}

article {
	max-width: 100vw;
	height: 100vh;
	display: grid;
	grid-template-rows: calc(100vh - var(--info-size)) var(--info-size);
	view-timeline: --article;
}

.article__img {
	position: sticky;
	top: 0;
	left: 0;
	right: 0;
	height: var(--info-size);
	animation: in-n-out both linear;
	animation-timeline: --article;
}

h2 {
	text-transform: uppercase;
	font-size: 2rem;
	margin: 0;
}

article img {
	object-fit: cover;
	width: 100%;
	height: 100%;
	height: calc(100vh - var(--info-size));
	animation: filter-out both linear;
	animation-timeline: --article;
	animation-range: exit 0% cover 100%;
}

@keyframes filter-out {
	100% {
		filter: brightness(2);
		translate: 0 -60%;
	}
}

@keyframes in-n-out {
	0%, 100% {
		opacity: 0;
	}
	10%, 60% {
		opacity: 1;
	}
}

.article__info {
	text-align: center;
	z-index: 2;
	background: hsl(0 0% 100%);
	display: grid;
	place-items: center;
	align-content: center;
	gap: 0.5rem;
	height: var(--info-size);
}

main {
	width: 100%;
}


a {
	text-transform: uppercase;
	font-weight: 600;
	color: hsl(0 0% 98%);
	background: hsl(0 0% 0%);
	padding: 1rem 2rem;
	text-decoration: none;
	word-spacing: 0.2rem;
	font-size: 1.25rem;
	border-radius: 4px;
	transition: background 0.1s;
}

a:hover {
	background: hsl(0 0% 40%);
}

@media(min-width: 768px) {
	article {
		width: 100%;
		display: grid;
		place-items: start;
		z-index: calc(var(--count, 10) - var(--index, 0));
		position: relative;
		grid-template-rows: unset;
	}
	nav {
		position: fixed;
		top: 0;
		z-index: 100;
	}
	.article__info {
		height: 100vh;
		width: 40%;
		display: grid;
		place-items: center;
		padding: 1rem;
		gap: 1rem;
		align-content: center;
	}
	.article__img {
		position: fixed;
		top: 0;
		right: 0;
		left: 40%;
		bottom: 0;
		height: 100vh;
		animation: none;
	}
  .article__img {
    animation: brighten both linear;
    animation-timeline: --article;
    animation-range: entry 0% entry 50%;
  }
	.article__img img {
		animation: clip-out both linear;
		animation-timeline: --article;
		animation-range: exit 0% exit 100%;
		height: 100%;
	}
}

@keyframes brighten {
  0% {
    filter: brightness(2);
  }
  100% {
    filter: brightness(1);
  }
}

@keyframes clip-out {
	0% {
		clip-path: inset(0 0 0 0);
	}
	100% {
    filter: brightness(0.5);
		clip-path: inset(100% 0 0 0);
	}
}

              
            
!

JS

              
                
              
            
!
999px

Console