Ich verwende Bootstrap v4 und bootstrap-select js/css (in ASP.NET MVC-Projekt) und ich habe ein Problem in meinem form
. Die select
mit multiple
Optionen von bootstrap-select
ist breiter als der Rest meiner inputs
, obwohl es in einem div
mit class="form-control"
ist. Die Ausgabe sieht etwa so aus: Bootstrap-Breite im Formular auswählen
Wie Sie sehen können, Expertise dropdown
ist viel größer als der Rest des inputs
. Ich habe versucht, bootstrap-select.css
zu bearbeiten und width:auto
ändern, aber hat nicht funktioniert. Gibt es etwas, was ich tun kann, um die width
meiner anderen inputs
übereinstimmen?
Mein Code sieht so etwas wie dieses
<div class="form-group">
@Html.LabelFor(v => v.BirthDate)
@Html.TextBoxFor(v => v.BirthDate, "{0:yyyy-MM-dd}", new { @class = "form-control", type = "date" })
@Html.ValidationMessageFor(v => v.BirthDate)
</div>
<div class="form-group">
@Html.LabelFor(v => v.ResidenceCountry)
@Html.TextBoxFor(v => v.ResidenceCountry, new { @class = "form-control" })
@Html.ValidationMessageFor(v => v.ResidenceCountry)
</div>
<div class="form-group">
@Html.LabelFor(m => m.CurrencyId)
@Html.DropDownListFor(m => m.CurrencyId, new SelectList(Model.Currencies, "Id", "Name"), "", new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.CurrencyId)
</div>
<div class="form-group">
@Html.LabelFor(m => m.FieldOfExpertiseIds)
@Html.ListBoxFor(m => m.FieldOfExpertiseIds, new MultiSelectList(Model.FieldOfExpertises, "Id", "Name"), new { @class = "selectpicker form-control", @data_selected_text_format = "count > 2", @data_size = "6" })
@Html.ValidationMessageFor(m => m.FieldOfExpertiseIds)
</div>
uptade:
ich jetzt die Form-Gruppe zu so etwas wie dies geändert (hinzugefügt @data_width = "auto"
):
<div class="form-group">
@Html.LabelFor(m => m.FieldOfExpertiseIds)
<br />
@Html.ListBoxFor(m => m.FieldOfExpertiseIds, new MultiSelectList(Model.FieldOfExpertises, "Id", "Name"), new { @class = "selectpicker form-control", @data_selected_text_format = "count > 2", @data_size = "6" , @data_width="auto" })
@Html.ValidationMessageFor(m => m.FieldOfExpertiseIds)
</div>
Und jetzt es sieht ein bisschen besser aus, aber immer noch ein Problem:
Nicht vertraut mit "selectpicker". Kommt das von einer Drittanbieter-Bibliothek? –
Ja, https://silviomoreto.github.io/bootstrap-select/ – Robert