问题
I have small design question about
html.DropDownListFor()
How can I change width of html.DropDownListFor()
??
For example by css.
Thanks for answers
回答1:
Have you tried Html.DropDownListFor( new {width:"100"})
or Html.DropDownListFor( new {@class:"longDropdownList"})
EDIT
<style>
.MakeWide { width: 200px; }
</style>
<%= Html.DropDownListFor(x => x.Name, new SelectList(new List<string>()), new { @class = "MakeWide" })%>
回答2:
@Html.DropDownListFor(x => x.Name, new SelectList(new List<string>()), new {style="width:270px;"} );
Will do the thing. Although better to use css class
回答3:
In C# you need add @, like this:
new { @style = "width: 350px;" }
来源:https://stackoverflow.com/questions/3049498/how-to-change-width-of-html-dropdownlistfor