[英]How to make ng-select width to fit placeholder and items?
I have the <nb-select>
with the following placeholder
:我有带有以下
placeholder
的<nb-select>
:
<nb-select id="weather" placeholder="Expected Weather" fullWidth>
<nb-option [value]="1">Dry</nb-option>
<nb-option [value]="2">Wet</nb-option>
</nb-select>
I'm trying to set width to be able auto fit it content to show not only items but the placeholder too.我正在尝试设置宽度以使其能够自动适应其内容以不仅显示项目而且显示占位符。
Tried to use 'fullWidth', but it works only for the options content:尝试使用“fullWidth”,但它仅适用于选项内容:
Checked a few solutions from the following posts:从以下帖子中检查了一些解决方案:
How to always display a placeholder of ng-select?如何始终显示 ng-select 的占位符?
Make ng-select width adjust to selected items / available options?使 ng-select 宽度调整为所选项目/可用选项?
Unfortunately it didn't work.不幸的是它没有用。
Thanks谢谢
The solution I found is to set min-width
to 100%
instead of using the fullWidth
:我找到的解决方案是将
min-width
设置为100%
而不是使用fullWidth
:
<nb-select placeholder="Expected Weather" [ngStyle]="{'min-width': '100%'}" id="weather">
<nb-option [value]="1">Dry</nb-option>
<nb-option [value]="2">Wet</nb-option>
</nb-select>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.