我想禁用文本区域的可调整大小属性。

目前,我可以通过单击文本区域的右下角并拖动鼠标来调整文本区域的大小。如何禁用此功能?


当前回答

要禁用所有文本区域的大小调整,请执行以下操作:

textarea {
    resize: none;
}

要禁用特定文本区域的大小调整,请添加属性、名称或id并将其设置为某个值。在本例中,它被命名为noresize

HTML

<textarea name='noresize' id='noresize'> </textarea>

CSS

/* Using the attribute name */
textarea[name=noresize] {
    resize: none;
}
/* Or using the id */

#noresize {
    resize: none;
}

其他回答

使用此属性调整大小:无;

textarea {
  resize: none;
}
<textarea style="resize:none" rows="10" placeholder="Enter Text" ></textarea>

正在添加!重要的使其发挥作用:

width:325px !important; height:120px !important; outline:none !important;

大纲只是为了避免某些浏览器上的蓝色大纲。

如果你需要深度支持,你可以使用一种老式的技巧:

textarea {
    max-width: /* desired fixed width */ px;
    min-width: /* desired fixed width */ px;
    min-height: /* desired fixed height */ px;
    max-height: /* desired fixed height */ px;
}

您需要在component.CSS中设置以下CSS代码

textarea {
    resize: none;
}