TextAreaFor Cannot Set Width

前端 未结 5 1460
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 06:24

I cannot set the width or cols in atextarea. Rows/Height works just fine. can someone please help thanks!

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken(         


        
5条回答
  •  迷失自我
    2021-02-07 06:36

    This appears to be a fall back to prevent the scaffolded views generating full width entry forms.

    However now we know that it is being set we can override it locally either in a class or directly on the element (shown purely for simplicity below).

    The key is to remember to set max-width to override the one in site.css as well as the width CSS property.

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

提交回复
热议问题