Make multiple-select to adjust its height to fit options without scroll bar

前端 未结 16 1049
说谎
说谎 2020-12-24 03:59

Apparently this doesn\'t work:

   select[multiple]{
     height: 100%;
   }

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

auto

16条回答
  •  北海茫月
    2020-12-24 05:00

    For jQuery you can try this. I always do the following and it works.

    $(function () {
       $("#multiSelect").attr("size",$("#multiSelect option").length);
    });
    

提交回复
热议问题