How to Create Interactive Scroll Effect to Columns in Gutenberg Editor

Table of Content

How about creating a scroll effect to your multi-column content? It’s pretty easy and adds a nice visual attraction to your web page.

So here is the sneak peek of what we are going to create in this quick tutorial.

Interactive Scroll Effect in Gutenberg

So let’s learn how you can create this nice effect in Gutenberg.

This is to work with multi-columns, so you may create any number of columns content as you like. And can have anything as your content in the columns.

I will just create something simple for this demo.

Image 2020-01-18 at 2.00.51 PM.png

Add a group block inside the column and add your content inside the group block using any Gutenberg Blocks you like.

Image 2020-01-18 at 2.04.17 PM.png

Now simply add content in other columns as well.

Image 2020-01-18 at 2.05.41 PM.png
Image 2020-01-18 at 2.07.30 PM.png

Now we have our content ready its time to apply some magic CSS to create a nice Interactive Scroll Effect.

Add a CSS class sticky-content to your main columns block. This is because we need to target this specific column block so that our CSS doesn’t interfere with other Columns you may have on the page.

Now, we need to add top padding to columns one, two and three. You need to increase the padding for each column.

  • Column one padding-top: 7vw;
  • Column tow padding-top: 20vw;
  • Column three padding-top: 32vw;
.sticky-content .wp-block-column:nth-child(1) {
padding-top:8vw !important;
}

.sticky-content .wp-block-column:nth-child(2) {
padding-top:20vw !important;
}

.sticky-content .wp-block-column:nth-child(3) {
padding-top:32vw !important;
}
Image 2020-01-18 at 2.34.59 PM.png

Now let’s add the following CSS to complete our Interactive Scroll Effect.

.sticky-content .wp-block-group {
position: sticky;
position: -webkit-sticky;
top: 8vw !important;
}

That is it. Now you should have nice interactive content but we need to limit this effect to desktop screen size as on mobile screen your columns are stacked so this effect should not work there. For that, we will simply limit our CSS to apply on Desktop screen sizes using CSS media queries.

Here is our final and complete CSS code.

@media only screen and (min-width: 980px) {
.sticky-content .wp-block-group {
position: sticky;
position: -webkit-sticky;
top: 8vw !important;
}
.sticky-content .wp-block-column:nth-child(1) {
padding-top:8vw !important;
}

.sticky-content .wp-block-column:nth-child(2) {
padding-top:20vw !important;
}

.sticky-content .wp-block-column:nth-child(3) {
padding-top:32vw !important;
}
}

Pretty simple and short CSS code. Here is the final result again.

Interactive Scroll Effect in Gutenberg

Hope this is useful to you. Do share what you create using this in the comments section. ?

💌

Unlock Exclusive Perks: Join Our VIP Subscriber Club Today!

Subscribe for special promotions, offers, freebies, and the latest updates and news – all exclusively for our VIPs. Don’t miss out, join now! 🌟💌🎁

We won’t send you spam, we promise.

Comments

Leave a Reply

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

Join the All Access Club

Your All-Inclusive Pass to Premium WordPress Products.