<分区>
我知道这篇文章可能与许多其他文章(例如 How to set the width of the text box when using Html.TextBoxFor)相同,但我在将 CSS 类分配给文本框时遇到了真正的麻烦。
我的 CSS 很简单:
.myInput {
width: 12em;
border-color: red;
}
我的文本框声明为:
@Html.TextBoxFor(model => model.DepostAmount, new {@class= "myInput"})
但是文本框的样式没有任何不同。查看页面的源代码,我可以看到该类确实包含在对象标记中:
<input class="myInput" id="DepostAmount" name="DepostAmount" type="text" value="" />
我还可以看到 .myInput 的 CSS 也被渲染了。