Categories
CSS

How to make div fixed scrolling to that div with CSS?

Spread the love

Sometimes, we want to make div fixed scrolling to that div with CSS.

In this article, we’ll look at how to make div fixed scrolling to that div with CSS.

How to make div fixed scrolling to that div with CSS?

To make div fixed scrolling to that div with CSS, we can use the position: sticky CSS property.

For instance, we write

position: -webkit-sticky;
position: sticky;
top: 0;
z-index: 1;

to set position to sticky and z-index to 1 to make the element with the sticky position show on top after we scroll to it.

Conclusion

To make div fixed scrolling to that div with CSS, we can use the position: sticky CSS property.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.