asp.net-mvc 如何改变 Html.TextBox 的宽度 [英] asp.net-mvc How to change width Html.TextBox
本文介绍了asp.net-mvc 如何改变 Html.TextBox 的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 asp.net-mvc 视图中更改文本框的宽度
how do you change the width of a textbox in an asp.net-mvc View
我希望将这些字段并排放置,并且状态文本框的宽度要短得多
i want to have these fields side by side and the state textbox much shorter width
<p>
<label for="city">City:</label>
<%= Html.TextBox("city")%>
<label for="state">State:</label>
<%= Html.TextBox("state")%>
</p>
以下答案似乎都不适合我.我注意到在 site.css 我看到了这个:
none of the below answers seem to work for me. I noticed that in site.css i see this:
fieldset p
{
margin: 2px 12px 10px 10px;
}
fieldset label
{
display: block;
}
fieldset label.inline
{
display: inline;
}
legend
{
font-size: 1.1em;
font-weight: 600;
padding: 2px 4px 8px 4px;
}
input[type="text"]
{
width: 200px;
border: 1px solid #CCC;
}
input[type="password"]
{
width: 200px;
border: 1px solid #CCC;
}
如何为一个字段(文本框)覆盖此行为
how do i override this behavior for one field (textbox)
推荐答案
我会使用带有 HTML 属性的辅助签名并为其分配一个 CSS 类.然后,您将使用 CSS 来实现所需的外观.
I would use the helper signature that takes HTML attributes and assign it a CSS class. You would then use CSS to achieve the desired look and feel.
<%= Html.TextBox( "state", null, new { @class = "small-input" } ) %>
这篇关于asp.net-mvc 如何改变 Html.TextBox 的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文