ASP.NET MVC Razor-DropDownList Width


@Html.DropDownListFor(model => model.MainAD, DepartmentList, new { htmlAttributes = new { @class = "form-control", @style = "width:80px" } })

为什么【@style="宽度:80px"】没有效果?

如何更改 html 的宽度。下拉列表对于 ?

<script>
$(document).ready(function () {
$('select').addClass("form-control");
});
</script>

假设DepartmentList是一种选择列表,则需要对代码进行轻微更改,而不是

@Html.DropDownListFor(model => model.MainAD, DepartmentList, new { htmlAttributes = new { @class = "form-control", @style = "width:80px" } })

@Html.DropDownListFor(model => model.MainAD, DepartmentList,htmlAttributes : new { @class = "form-control", @style = "width:80px" })

htmlAttributes 是 DropDownListFor 的参数,而不是参数的属性

相关内容

  • 没有找到相关文章

最新更新