Setting the height of a div container by only x amount of elementswithin it

T

Thierry Lam

I have the following div container:

<div id="the_container">
<input type="checkbox" name="item" /><br />
<input type="checkbox" name="item" /><br />
...
<input type="checkbox" name="item" /><br />
</div>

Let's say I have about 50 checkboxes in the above. I want to add a
scrollbar in the above so that its minimum height is 10 checkboxes.
How can I write a javascript to calculate the height of 10 checkboxes
so that the scrollbar will always show at least 10 checkboxes in any
browsers?
 
S

SAM

Le 4/16/09 9:46 PM, Thierry Lam a écrit :
I have the following div container:

<div id="the_container">
<input type="checkbox" name="item" /><br />

<label for="c_01">choice 1:
<input type="checkbox" name="item" id="c_01" />
<input type="checkbox" name="item" /><br />

<label ...
...
<input type="checkbox" name="item" /><br />
</div>

Let's say I have about 50 checkboxes in the above. I want to add a
scrollbar in the above so that its minimum height is 10 checkboxes.
How can I write a javascript to calculate the height of 10 checkboxes
so that the scrollbar will always show at least 10 checkboxes in any
browsers?

and, of course, no half checkbox (or half label) with any scroll ?
 
R

rf

Thierry said:
I have the following div container:

<div id="the_container">
<input type="checkbox" name="item" /><br />
<input type="checkbox" name="item" /><br />
...
<input type="checkbox" name="item" /><br />
</div>

Let's say I have about 50 checkboxes in the above. I want to add a
scrollbar in the above so that its minimum height is 10 checkboxes.
How can I write a javascript to calculate the height of 10 checkboxes
so that the scrollbar will always show at least 10 checkboxes in any
browsers?

Find the height of one checkbox.

Multiply by 10.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top