Make multiple-select to adjust its height to fit o

2019-01-21 21:21发布

Apparently this doesn't work:

   select[multiple]{
     height: 100%;
   }

it makes the select have 100% page height...

auto doesn't work either, I still get the vertical scrollbar.

Any other ideas?

enter image description here

13条回答
We Are One
2楼-- · 2019-01-21 21:57

To adjust the size (height) of all multiple selects to the number of options, use jQuery:

$('select[multiple = multiple]').each(function() {
    $(this).attr('size', $(this).find('option').length)
})
查看更多
登录 后发表回答