Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 MVC 中为标签设置特定宽度?
以下方法不包含HtmlAttributes属性。
HtmlAttributes
@Html.Label
注意:我正在从控制器读取标签的宽度。它是动态的。
该方法@Html.Label确实具有 HtmlAttributes 属性。
所以应该这样做:
@Html.Label("my label", new {style = "width: 10px;"})
How about new {@class = "myclass"} and set the width in css?
您可以为标签编写 CSS。这样一个 CSS 就可以设置所有标签的宽度