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

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


当前回答

您可以像这样简单地禁用textarea属性:

textarea {
    resize: none;
}

要禁用垂直或水平调整大小,请使用

resize: vertical;

or

resize: horizontal;

其他回答

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

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;
}

您也可以尝试使用jQuery

$('textarea').css("resize", "none");

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

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

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

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

textarea {
  resize: none;
}

在CSS中。。。

textarea {
    resize: none;
}