Reputation: 944
I have been searching to find out how to change the width
of @Html.DropDownList
for the selected item without any success. For design purposes, I would like to set it to 450px
, but it seems it doesn't go above 300
. Would that be a limitation?
@Html.DropDownList("AddressID", null, htmlAttributes: new { style = "width:450px" })
It seems that new { style="width:450px" }
only changes the width of the options; not the selected area. While researching, I found out how to change the height
of selected item by using size
as in new { size="20" }
. So I tried using new { width = "450" }
but no success. Length
also doesn't work. :(
I would appreciate any help I could get. Thanks!
Upvotes: 1
Views: 2572
Reputation: 1151
in case you are using Bootstrap there are max-width
rule applied to the Select
Tag.
try this it worked for me:
@Html.DropDownList("AddressID", null, htmlAttributes: new { @class="form-control", style = "width:450px;max-width:450px;" })
Upvotes: 5