Please review these two <select>
elements:
<select>
<option>one</option>
<option>one</option>
<option>one</option>
<option>one</option>
<option>one</option>
<option>one</option>
<option>one</option>
</select>
<select>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
<option>two</option>
</select>
Upon observation, the first select box is fixed, while the second is scrollable. Therefore, if I include multiple <option>
elements in a <select>
, it automatically becomes scrollable.
I am seeking ways to limit this auto-scroll feature by reducing the number of displayed <option>
. For instance, can I configure a <select>
with only 7 options to display a scrollbar? Is this achievable through JavaScript?
I attempted wrapping the <select>
within a <div>
and setting its height
restriction, but no changes occurred.