My HTML code includes a <select>
element that is styled using Bootstrap 5.
<div class="col-md-12">
<div class="mb-3">
<label asp-for="Schedule.Minutes" class="control-label"></label>
<select asp-for="Schedule.Minutes" class="form-control" asp-items="Model.MinutesOptions"></select>
<span asp-validation-for="Schedule.Minutes" class="text-danger"></span>
</div>
</div>
I have applied the class="form-control"
to ensure consistent styling with my other elements. However, this causes the select element to stretch across the full width of its container by default.
In this scenario, I would like the select element to only be as wide as necessary to display its longest option in the list.
Is there an option in Bootstrap to achieve this layout?