<分区>
<分区>
.option100{
width:100px !important;
}
<select id="fieldOfInterestSelect" name="fieldOfInterest" class="form-control" required="">
<option value="-1">SELECT ONE</option>
<option value="4893" class="option100">Actual(R)rrrrrrrrrrrrrrrr</option>
<option value="4891" class="option100">Customerrrrrrrrrrrrrr</option>
<option value="4892" class="option100">Daterrrrrrr</option>
<option value="4894" class="option100">Forecast(R)RRRRRR</option>
</select>
我担心的是,如果选项中文本的长度大于其容器的长度 (option
),那么它应该自动转换(适合)为多行以适合容器的宽度。
最佳答案
这可能不是您想要的,但您可以通过使用“optgroup”标签为每个选项获取两行
<select>
<optgroup label="Option 1">
<option value="yes">Option 1 new Line</option>
</optgroup>
<optgroup label="Option 2">
<option value="no">Option 2 new line</option>
</optgroup>
</select>
您可以从此链接找到有关此主题的更多详细信息 enter link description here
关于html - 选择选项宽度自动增加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43405896/