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

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


当前回答

要禁用resize属性,请使用以下CSS属性:

resize: none;

您可以将其应用为内联样式属性,如下所示:<textarea style=“resize:none;”></textarea>或介于<style>之间</style>元素标记如下:文本区域{调整大小:无;}

其他回答

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

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

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

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

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

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

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

textarea {
    resize: none;
}

CSS 3可以解决这个问题。不幸的是,现在只有60%的浏览器支持它。

对于Internet Explorer和iOS,您不能关闭调整大小,但可以通过设置文本区域的宽度和高度来限制文本区域的大小。

/* One can also turn on/off specific axis. Defaults to both on. */
textarea { resize:vertical; } /* none|horizontal|vertical|both */

参见演示