这是我的css:
.editor-field textarea {
    width : 400;
    height : 100px;
}
以下是我认为的标记:
        <div class="editor-field">
            @Html.EditorFor(model => model.Visit.BehavioralObservations)
            @Html.ValidationMessageFor(model => model.Visit.BehavioralObservations)
        </div>
这是我的模型的注释显示MultilineText属性:
    [DisplayName("Behavioral Observations")]
    [DataType(DataType.MultilineText)]
    public string BehavioralObservations { get; set; }
为什么我不能设置这个textarea的宽度?我可以在CSS中调整高度,看起来是正确的(使用Chrome Developer工具验证),但宽度不会改变.Chrome表示宽度是无效的属性值,并且对属性应用了一个删除线以及在该属性旁边显示的黄色三角形.
仅供参考,这不仅限于Chrome.IE8也有同样的问题.
思考?我该如何解决?谢谢!
vfa*_*bre 52
尝试使用TextAreaForhelper方法和set cols和rowshtml属性
样品
@Html.TextAreaFor(model=>model.MyMultilineText, new {rows="6", cols="10"})
我希望这有帮助.问候.
Mic*_*uso 30
你离开了px:
.editor-field textarea {
    width : 400px;
    height : 100px;
}
f4d*_*4d0 15
经过一段时间搜索它,最好的方法是使用方法TextAreaFor()的一个重载
@Html.TextAreaFor(model => model.Visit.BehavioralObservations, 10, 40, new { HtmlAttributes = new { } })
10是行数,40是列数
小智 6
代码:
@Html.TextAreaFor(m => m.Message, 30, 10, new { @class = "what" })
ASP MVC默认的项目有site.css与 
max-width:280对textarea-删除和尝试这样的事情
@Html.TextAreaFor(model => model.ComicText, new { style = "width: 700px; height:150px;" }) 
| 归档时间: | 
 | 
| 查看次数: | 68599 次 | 
| 最近记录: |