最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Need to fix height and width of select2 multiple-select search box - Stack Overflow

programmeradmin4浏览0评论

As and when I keep selecting multiple options in a select2 element, the text-area displaying the current selections keeps expanding, like the below:

I tried fix height of classes like select2-selection and select2-container. That did not help me. I ended up with something like the below.

My requirement - I want to fix the height and width of the text area and all the options must be rendered within it. (Since, this will be part of a small pop-up and there are size restrictions).

As and when I keep selecting multiple options in a select2 element, the text-area displaying the current selections keeps expanding, like the below:

I tried fix height of classes like select2-selection and select2-container. That did not help me. I ended up with something like the below.

My requirement - I want to fix the height and width of the text area and all the options must be rendered within it. (Since, this will be part of a small pop-up and there are size restrictions).

Share Improve this question asked Mar 30, 2015 at 11:38 SriramSriram 5111 gold badge3 silver badges15 bronze badges 2
  • Could you please provide your question with test example – Maxim Zhukov Commented Mar 30, 2015 at 11:42
  • Point taken - I will use jsfiddle the next time I post a question. Thanks! – Sriram Commented Mar 30, 2015 at 11:57
Add a ment  | 

1 Answer 1

Reset to default 13

This turned out to be fairly simple. There was a span element of class select2-selection--multiple as the parent of the lis. All I had to do was add overflow-y: auto and that did the trick. I was not aware of this property.

My select2 bobox, now, looks like the below.

For my further reading - overflow-y description in w3schools

发布评论

评论列表(0)

  1. 暂无评论