如何在 html razor view mvc4 中增加 TextArea 的大小?

新手上路,请多包涵

在我看来,我有一个名为 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 字段不会缩小到页面大小。这是问题

我一直在验证我的领域。我想用红色显示该验证。我正在使用模型验证。

原文由 Susan 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 657
1 个回答

试试这个:

   @Html.TextAreaFor(model => model.Description, 10,40, htmlAttributes: new {style="width: 100%; max-width: 100%;" })

原文由 error_handler 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题