</div>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/2836827/how-do-you-add-a-scroll-bar-to-a-div" dir="ltr">How do you add a scroll bar to a div?</a>
<span class="question-originals-answer-count">
(5 answers)
</span>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2014-09-05 10:53:05Z" class="relativetime">5 years ago</span>.</div>
</div>
</aside>
I've got a DIV which is supposed to hold multiple DIVs inside it. How can I set a scroll bar to a DIV?
<div id="container"> //need a scroller to this div
<div id="subcontainer1"></div>//created dynamically
<div id="subcontainer2"></div>//created dynamically
<div id="subcontainer3"></div>//created dynamically
more created dynamically....
</div>
</div>
Add this code to your stylesheet overflow:scroll
or overflow:auto
#container{
overflow:auto;
}
Hope it helps
Give it a fixed height using the height
property and then set overflow:auto
or overflow:scroll
Here's the demo http://jsfiddle.net/vinith98/oyug02xz/1/
.wrapper-div {
overflow: auto;
width: 12%;
height: 80%;
}
Use the above class(.wrapper-div) for the div for which you want to have scroll bars. specify width and height.