Scrollbar on a select

0

How do I use a scroll bar to scroll in a select? For example:

<select>
  <option>a</option>
  <option>b</option>
  <option>c</option>
  <option>d</option>
  <option>e</option>
  <option>f</option>
  <option>g</option>
</select>

Do you have a scroll to the box that goes down does not get too big? You should list all below only 3 and then be able to scroll down.

    
asked by anonymous 31.03.2016 / 22:41

2 answers

3
select{
   overflow-y:auto;
}

<select size='3'>
  <option>a</option>
  <option>b</option>
  <option>c</option>
  <option>d</option>
  <option>e</option>
  <option>f</option>
  <option>g</option>
</select>

UPDATING

You can use the bootstrap plugin select, as far as I understand, you want to control the height of the box that opens when you click the select. Bootstrap select has this feature, see:

The attribute used is data-size

<select class="selectpicker" data-size="2">
  <option>Mustard</option>
  <option>Ketchup</option>
  <option>Relish</option>
</select>

Example running here: link

Bootstrap select has dependencies, they are: Jquery and Bootstrap

I hope you can solve your problem now.

    
31.03.2016 / 22:57
-1

This for me is the easiest way in case "max-height" will limit the size of the modal and "overflow" automatically generates the scroll.

<div style="max-height: 15vh; overflow: auto;"> <select> <option>a</option> <option>b</option> <option>c</option> <option>d</option> <option>e</option> <option>f</option> <option>g</option> </select> </div>

    
09.11.2018 / 11:28