Search code examples
htmlscrollfixed

Fixed size of div


I have added a scroll bar to my div tag. However, the size of this window dynamically grow according to the text size, and therefore the scroll bar is disabled.

<div style="overflow:scroll;width: 650px;font-size: 14px;margin-top: 50px;display:None" id="loader" class="tr-bg tr-internal-frame" onclick='$("#workNow").toggle()'></div>

I guess that i need to fix the size of the window, and then the scroll bar will be enabled. Is it right? If so, how can i do that?


Solution

  • You need to give the div a fixed height. Try this:

    <div style="overflow:scroll;width: 650px; height:100px; font-size: 14px;margin-top: 50px;display:None" id="loader" class="tr-bg tr-internal-frame" onclick='$("#workNow").toggle()'></div>
    

    Here is a Demo for the same.