如何使用CSS设置文本区域的宽度和高度? [英] How do I set the width and height of a textarea using CSS?

查看:484
本文介绍了如何使用CSS设置文本区域的宽度和高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的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属性:

And here is the annotation of my model showing the MultilineText attribute:

    [DisplayName("Behavioral Observations")]
    [DataType(DataType.MultilineText)]
    public string BehavioralObservations { get; set; }

为什么我不能设置该文本区域的宽度?我可以在CSS中调整高度,并且看起来正确(已通过Chrome开发者工具验证),但宽度没有变化. Chrome表示宽度是无效的属性值,并且对属性应用了删除线,并在属性旁边显示了一个黄色三角形.

Why can't I set the width of this textarea? I can adjust the height in my CSS and it looks correct (verified with Chrome Developer tools) but the width doesn't change. Chrome says the width is an invalid property value and has a strike-through applied to the property along with a yellow triangle displayed adjacent to the property.

仅供参考,这不仅限于Chrome. IE8也有同样的问题.

FYI, this is not limited to Chrome. IE8 has the same issue.

有什么想法吗?我该如何解决?谢谢!

Thoughts? How do I fix this? Thanks!

推荐答案

您放弃了px:

.editor-field textarea {
    width : 400px;
    height : 100px;
}

这篇关于如何使用CSS设置文本区域的宽度和高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆