如何在 html razor view mvc4 中增加 TextArea 的大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36995463/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Increase the size of TextArea in html razor view mvc4?
提问by Susan
I have one text area field called Descriptionin my view. I wish to increase the size of that field.
在我看来,我有一个名为Description 的文本区域字段。我希望增加该字段的大小。
My code
我的代码
<div class="col-sm-3">
<div class="form-group">
<span style="color: #f00">*</span>
@Html.LabelFor(model => model.Description, new { @class = "control-label" })
@Html.TextAreaFor(model => model.Description, new { @class = "required", style = " rows=10, columns=40" })
@Html.ValidationMessageFor(model => model.Description)
</div>
</div>
My TextArea
我的文本区
I want to bring as like which is mention in the below image
我想带来下图中提到的
So i gave Rows and columns in textarea field. It increase the size of the text area. But when i shrink the page to phone size means all fields got shrink . But this textarea field is not shrink up to the page size. This is the issue
所以我在 textarea 字段中给出了行和列。它增加了文本区域的大小。但是当我将页面缩小到手机大小时,意味着所有字段都缩小了。但是这个 textarea 字段不会缩小到页面大小。这是问题
I kept validation for my fields. I want to show that validation in Red color. I'm using Model validation.
我一直在验证我的领域。我想以红色显示该验证。我正在使用模型验证。
回答by error_handler
Try This:
尝试这个:
@Html.TextAreaFor(model => model.Description, 10,40, htmlAttributes: new {style="width: 100%; max-width: 100%;" })
回答by Twaya
While this is already answered, Someone out there might still need this.
虽然这已经得到了回答,但外面的人可能仍然需要这个。
@Html.TextAreaFor(model => model.comments,
new { @cols = "100", @rows = "8", @style="width:100%;"})
回答by Guruprasad Rao
Rows
and Cols
does not come under style
tag. Its an independent attribute for textarea
. You can write it as below.
Rows
并且Cols
不属于style
标记。它是 的独立属性textarea
。你可以写成如下。
@Html.TextAreaFor(model => model.Description, new { @class = "required", @cols = 40, @rows = 10})
回答by Jitu Joshi
Remove textArea element from site.css file. In site.css textarea max-width set as 280px;
Do like
input
,select
/*,textarea*/
{
max-width: 280px;
}
回答by Felix
@Html.TextAreaFor(m => m.Description, 10, 40, new { @class = "form-control required", style="max-width:75% !important;" })
回答by Zufan Tadese
@Html.TextAreaFor(model => model.Description, new { @class = "form-control", @cols = 10, @rows = 10,@style="resize:both;" })