简体   繁体   中英

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

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).

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

My select2 combobox, now, looks like the below.

在此输入图像描述

For my further reading - overflow-y description in w3schools

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM