CSS - 控制 textarea 是否可调整大小

文章目录


In most browsers, <textarea>s are resizable — you’ll notice the drag handle in the right hand corner, which can be used to alter the size of the element on the page. This is controlled by the resize CSS property — resizing is enabled by default, but you can explicitly disable it using a resize value of none:

在大多数浏览器中,<textarea> 可被调整大小 —— 你会注意到在右下角的拖动手柄,它可以用来改变页面上元素的大小。这是由 resize CSS 属性控制的 —— 默认情况下,是允许调整大小的,但是你可以使用 resize 的值 none 明确地禁用它:

textarea {
  	resize: none;
}

示例

CSS - 控制 textarea 是否可调整大小

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <style type="text/css">
            textarea {
                width: 300px;
                height: 200px;
            }
        </style>
    </head>
    <body>
        <textarea>可以调整大小,观察右下角的区别。</textarea>
        <textarea style="resize: none;">不可调整大小,观察右下角的区别。</textarea>
    </body>
</html>

参考

Controlling whether a textarea is resizable

上一篇:textarea如何实现高度自适应?


下一篇:【js】【笔记】普通js常用