Omri
Omri

Reputation: 1646

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?

Upvotes: 0

Views: 2572

Answers (2)

Dhara
Dhara

Reputation: 1972

Just set height in css of div tag.. try this code

div{
  border:1px solid black;
  height:100px; //ADD THIS
  width:100px;
  overflow:scroll;
}
<div>
a
b
c
c
d
e
f
g
h
i
j
k
l

m
o
p


z
.
.
.

</div>

Upvotes: 1

Senjuti Mahapatra
Senjuti Mahapatra

Reputation: 2590

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.

Upvotes: 2

Related Questions