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

示例

在这里插入图片描述

<!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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值