简体   繁体   English

如何设置语义 UI 下拉菜单的宽度

[英]How to set the width of Semantic UI dropdown

How can I set the width of the Semantic UI Search Selection drop down?如何设置语义 UI 搜索选择下拉菜单的宽度? I need to set the width of Semantic UI Search selection dropdown to the longest element in the dropdown.我需要将语义 UI 搜索选择下拉列表的宽度设置为下拉列表中最长的元素。 Any help will be appreciated.任何帮助将不胜感激。

I used a fixed-size wrapper combined with a fluid (expands to fit size of parent) dropdown nested inside of it我使用了一个固定大小的包装器和一个嵌套在它里面的流体(扩展到适合父级的大小)下拉菜单

<div style="width: 250px;">
  <div class="ui fluid dropdown">
    <input type="hidden" name="country">
    <div class="default text">My Dropdown Text</div>
  </div>
</div>

Try setting the min-width instead of setting the width .尝试设置min-width而不是设置width The default is a min-width of 14em , so you'll need to override that if you wish to have a smaller width.默认值为14emmin-width ,因此如果您希望具有较小的宽度,则需要覆盖它。

Example:例子:

.ui.dropdown.search{
     min-width: /*smaller width here*/;
}

Try using the 'compact' attribute as shown below.尝试使用 'compact' 属性,如下所示。 However it only adjusts the width based on what is selected.但是,它仅根据所选内容调整宽度。

<div class="ui compact selection dropdown">
  <i class="dropdown icon"></i>
  <div class="text">Compact</div>
  <div class="menu">
    <div class="item">A</div>
    <div class="item">B</div>
    <div class="item">C</div>
  </div>
</div>

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

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