[英]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: 当我继续在select2元素中选择多个选项时,显示当前选择的文本区域将继续扩展,如下所示:
I tried fix height of classes like select2-selection
and select2-container
. 我尝试修复类的高度,如
select2-selection
和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. 有一个类
select2-selection--multiple
的span元素select2-selection--multiple
作为li
的父元素。 All I had to do was add overflow-y: auto
and that did the trick. 我所要做的就是添加
overflow-y: auto
,这就是诀窍。 I was not aware of this property. 我不知道这个属性。
My select2 combobox, now, looks like the below. 我的select2组合框现在看起来如下所示。
For my further reading - overflow-y description in w3schools 对于我的进一步阅读 - 在w3schools溢出y描述
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.