Asp.net

如何更改 html.DropDownListFor() 的寬度

  • December 22, 2021

我有一個關於設計的小問題

html.DropDownListFor() 

如何更改寬度html.DropDownListFor()?例如通過 css。

感謝您的回答

你有沒有嘗試過Html.DropDownListFor( new {width:"100"})

或者Html.DropDownListFor( new {@class:"longDropdownList"})

編輯

<style>
   .MakeWide { width: 200px; }
</style>

<%= Html.DropDownListFor(x => x.Name, new SelectList(new List<string>()), new { @class = "MakeWide" })%>

如果您使用的是 Bootstrap,它會在 site.css 中將最大寬度設置為 280 像素。

您可能不想更改它,以便為單個控制項集覆蓋它:

new { style = "max-width:100%:width:350px" }

引用自:https://stackoverflow.com/questions/3049498