1

如何在 MVC 中为标签设置特定宽度?

以下方法不包含HtmlAttributes属性。

@Html.Label

注意:我正在从控制器读取标签的宽度。它是动态的。

4

3 回答 3

2

该方法@Html.Label确实具有 HtmlAttributes 属性。

所以应该这样做:

@Html.Label("my label", new {style = "width: 10px;"})
于 2013-04-21T12:27:33.687 回答
1

How about new {@class = "myclass"} and set the width in css?

于 2013-04-22T04:38:56.390 回答
0

您可以为标签编​​写 CSS。这样一个 CSS 就可以设置所有标签的宽度

于 2013-04-22T07:47:13.123 回答