gpt4 book ai didi

css - 如何用很长的文本限制选项宽度

转载 作者:太空宇宙 更新时间:2023-11-03 17:28:23 25 4
gpt4 key购买 nike

我试过了,但当文本很长时无法控制选项宽度。如何限制选项的宽度或至少与选择相同。使用 Bootstrap 和 asp.net mvc

http://i.stack.imgur.com/cAQta.png

CSS如下

input,
select,
textarea {
max-width: 280px;
}

select{
width:200px
}

代码就是普通的mvc

<div class="form-group">
@Html.LabelFor(model => model.UserInfoId, "Choose Masseur", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("UserInfoId", null, "No preference", htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.UserInfoId, "", new { @class = "text-danger" })
</div>
</div>

生成的html如下

<div class="form-group">
<label class="control-label col-md-2" for="UserInfoId">Choose Masseur</label>
<div class="col-md-10">
<select class="form-control" id="UserInfoId" name="UserInfoId"><option value="">No preference</option>
<option selected="selected" value="2">Lisa lee : Although she looks young, but Lisa is very experienced in curing massage, slim down massage and ease insomnia problem. She is working from 9pm to 9am (night shift), better place an online booking or call 65547388 for a booking, she is always fully booked every day.</option>
<option value="3">Wendy lee : Wendy is from Vietnam,experienced, very kind and nice to talk, she can speak in Chinese and English. Off on Saturday. </option>
</select>
<span class="field-validation-valid text-danger" data- valmsg-for="UserInfoId" data-valmsg-replace="true"></span>
</div>
</div>

最佳答案

可能有助于解决您的问题

<div class="form-group">
<label class="control-label col-md-2" for="UserInfoId">Choose Masseur</label>
<div class="col-md-10">
<select class="form-control" id="UserInfoId" name="UserInfoId" multiple="multiple" style="font-size:large" >
<option value="">No preference</option>
<option selected="selected" value="2">Lisa lee : Although she looks young, but Lisa is very experienced in curing massage, slim down massage and ease insomnia problem. She is working from 9pm to 9am (night shift), better place an online booking or call 65547388 for a booking, she is always fully booked every day.</option>
<option value="3">Wendy lee : Wendy is from Vietnam,experienced, very kind and nice to talk, she can speak in Chinese and English. Off on Saturday. </option>
</select>

关于css - 如何用很长的文本限制选项宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31064527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com