I have this div:
<div style='overflow:scroll; width:400px;height:400px;'>here is some text</div>
The scrollbars are always visible, even though the text does not overflow. I want to make the scrollbars only be visible when necessary - that is, only visible when there is enough text in the box that they are needed. Like a textarea does. How do I do this? Or is my only option to style a textarea so it looks like a div?
I found that there is height of div still showing, when it have text or not. So you can use this for best results.
<div style=" overflow:auto;max-height:300px; max-width:300px;"></div>
try
<div id="boxscroll2" style="overflow: auto; position: relative;" tabindex="5001">
try this:
<div style='overflow:auto; width:400px;height:400px;'>here is some text</div>
You can try with below one:
<div style="width: 100%; height: 100%; overflow-x: visible; overflow-y: scroll;">Text</div>
try
<div style='overflow:auto; width:400px;height:400px;'>here is some text</div>
Source: Stackoverflow.com