简体   繁体   English

select2使容器宽度适合文本

[英]select2 make container width fit text

I'm looking for a way to increase the width of the container so that the text fits, instead of having it be truncated with ... 我正在寻找一种方法来增加容器的宽度,以使文本适合,而不是用...截断它...

在此处输入图片说明

I can't seem to get the container css attributes working eg containerCss . 我似乎无法使容器css属性正常工作,例如containerCss I get the error Uncaught Error: No select2/compat/containerCss . 我收到错误Uncaught Error: No select2/compat/containerCss

I'm using select2 via npm 我正在通过npm使用select2

Right click and inspect the html text input and look at its class name. 右键单击并检查html文本输入,然后查看其类名。 use chrome inpector and experement setting the width css attribute on those generated elements. 使用chrome inpector和experement在生成的元素上设置width css属性。 Find the corresponding css class. 找到相应的CSS类。 Also look at the class names of its container element. 还要查看其容器元素的类名称。 Set the css of those elements to find a desired result. 设置这些元素的css以找到所需的结果。 Then on the html page with the jquery selector library use the relevant class names and set the width. 然后在带有jquery选择器库的html页面上,使用相关的类名称并设置宽度。 Alternitevly read the docs on jquery select library on css styling. 或者,阅读有关CSS样式的jquery select库的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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