Asp.net mvc 3 如何覆盖Html.TextBoxFor的输入[type=";text";]?
我想在视图中设置一个特定文本框的宽度。无论我尝试了什么,Site.css中的以下代码优先:Asp.net mvc 3 如何覆盖Html.TextBoxFor的输入[type=";text";]?,asp.net-mvc-3,Asp.net Mvc 3,我想在视图中设置一个特定文本框的宽度。无论我尝试了什么,Site.css中的以下代码优先: input[type="text"], input[type="password"] { // other properties width: 200px; } 我试过: @Html.TextBoxFor(model => model.Headline, new { style = "width: 400" }) 及 及 但唯一重要的是输入[type=“text”]的宽度。我不想改变所有
input[type="text"], input[type="password"]
{
// other properties
width: 200px;
}
我试过:
@Html.TextBoxFor(model => model.Headline, new { style = "width: 400" })
及
及
但唯一重要的是输入[type=“text”]的宽度。我不想改变所有的输入,只想改变这个
我在.css文件中设置了.wide和#headline的宽度。为什么不使用then input[name=“name”]或id作为示例?如果你想让一种风格比另一种更重要,那就使用它吧!在css属性的末尾显示重要信息。比如:
input[type="text"] {
width: 200px;
}
input[name="foo"] {
width: 500px !important;
}
希望这能有所帮助。随你的便
.wide {
width: 500px !important;
}
@Html.TextBoxFor(model => model.Headline, new { class = "wide" })
或
谢谢如果我把你的建议放在CSS文件的默认“输入”设置之后,那么我以前尝试过的所有建议都会起作用。
input[type="text"] {
width: 200px;
}
input[name="foo"] {
width: 500px !important;
}
.wide {
width: 500px !important;
}
@Html.TextBoxFor(model => model.Headline, new { class = "wide" })
#wideBox {
width: 500px;
}
@Html.TextBoxFor(model => model.Headline, new { id = "wideBox" })