asp.net-MVC如何更改宽度Html.TextBox [英] asp.net-mvc How to change width Html.TextBox

查看:1210
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆