CSS-Only Section Wipes

Written by
Published
Typical Read
1 minutes

Throw away the JavaScript, put down the libraries, say good-bye to ScrollMagic section wipes, and hello to CSS-only section wipes. Learn how to create scroll wipes with sticky containers.

tl;dr

<section>
  <h2>Section 1</h2>
  <p>Vestibulum id ligula porta felis euismod semper.</p>
</section>
<section>
  <h2>Section 2</h2>
  <p>Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
</section>
<section>
  <h2>Section 3</h2>
  <p>Donec id elit non mi porta gravida at eget metus.</p>
</section>
section {
  bottom: 0;
  min-height: 95vh;
  left: 0;
  right: 0;
  position: sticky;
}

section:nth-child(1) {
  background: #000;
  z-index: 3;
}

section:nth-child(2) {
  background: #ccc;
  z-index: 2;
}

section:nth-child(3) {
  background: #fff;
  z-index: 1;
}

Join the conversation.

Your email address will not be published. Required fields are marked *

All comments posted on 'CSS-Only Section Wipes' are held for moderation and only published when on topic and not rude. Get a gold star if you actually read & follow these rules.

You may write comments in Markdown. This is the best way to post any code, inline like `<div>this</div>` or multiline blocks within triple backtick fences (```) with double new lines before and after.

Want to tell me something privately, like pointing out a typo or stuff like that? Contact Me.