Sometimes, we want to make the scrollbar on a div only visible when necessary with CSS.
In this article, we’ll look at how to make the scrollbar on a div only visible when necessary with CSS.
How to make the scrollbar on a div only visible when necessary with CSS?
To make the scrollbar on a div only visible when necessary with CSS, we set the overflow
property.
For instance, we write
<div style="overflow: auto; width: 400px; height: 400px">here is some text</div>
to add the overflow: auto;
style to make the scrollbars show when there’s overflowing content.
Conclusion
To make the scrollbar on a div only visible when necessary with CSS, we set the overflow
property.