How to make a div vertically scrollable using CSS?

Spread the love

Sometimes, we want to make a div vertically scrollable using CSS.

In this article, we’ll look at how to make a div vertically scrollable using CSS.

How to make a div vertically scrollable using CSS?

To make a div vertically scrollable using CSS, we set overflow to auto.

For instance, we write

div {
  overflow: auto;
  max-height: 100vh;
}

to set the div’s max-height and overflow to auto to make the div vertically scrollable by restricting its height and allow us to scroll to see overflowing content.

Conclusion

To make a div vertically scrollable using CSS, we set overflow to auto.

Leave a Reply

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