[英]How to Increase the size of TextArea in html razor view mvc4?
在我看来,我有一个名为Description 的文本区域字段。 我希望增加该字段的大小。
我的代码
<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>
我的文本区
我想带来下图中提到的
所以我在 textarea 字段中给出了行和列。 它增加了文本区域的大小。 但是当我将页面缩小到手机大小时,意味着所有字段都缩小了。 但是这个 textarea 字段不会缩小到页面大小。 这是问题
我一直在验证我的领域。 我想以红色显示该验证。 我正在使用模型验证。
试试这个:
@Html.TextAreaFor(model => model.Description, 10,40, htmlAttributes: new {style="width: 100%; max-width: 100%;" })
虽然这已经得到了回答,但外面的人可能仍然需要这个。
@Html.TextAreaFor(model => model.comments,
new { @cols = "100", @rows = "8", @style="width:100%;"})
Rows
和Cols
不属于style
标签。 它是textarea
的独立属性。 你可以写成如下。
@Html.TextAreaFor(model => model.Description, new { @class = "required", @cols = 40, @rows = 10})
Remove textArea element from site.css file. In site.css textarea max-width set as 280px;
Do like
input
,select
/*,textarea*/
{
max-width: 280px;
}
@Html.TextAreaFor(m => m.Description, 10, 40, new { @class = "form-control required", style="max-width:75% !important;" })
@Html.TextAreaFor(model => model.Description, new { @class = "form-control", @cols = 10, @rows = 10,@style="resize:both;" })
@Html.TextAreaFor(model => model.Description,10,40, new { @class = "required"})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.