用Select2包装所选文本

如何将Select2中的选定文本换行而不是使用省略号? 选项包装,但我希望输入字段能够向下扩展而不是结束。

这是一个例子

$('.select2').select2(); 
     Really long name that normally wouldn't be visible Alaska Arizona  

默认情况下, Select2添加以下代码 :

 .select2-selection--single { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } 

但是,删除这些属性并不起作用,因为它们仍然嵌套在其他容器中。

我认为是.select2-selection__rendered元素需要一些调整。 这样的事怎么样?

 .select2-selection--single { height: 100% !important; } .select2-selection__rendered{ word-wrap: break-word !important; text-overflow: inherit !important; white-space: normal !important; } 

 $('.select2').select2(); 
 .select2-selection--single { height: 100% !important; } .select2-selection__rendered{ word-wrap: break-word !important; text-overflow: inherit !important; white-space: normal !important; }