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

前端 未结 16 1122
说谎
说谎 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 04:42

    I had this requirement recently and used other posts from this question to create this script:

    $("select[multiple]").each(function() {
      $(this).css("height","100%")
        .attr("size",this.length);
    })
    

提交回复
热议问题