larry*wei 2011-03-08 16:15 采纳率: 0%
浏览 1038
已采纳

如何禁用 textarea 的可调整属性?

I want to disable the resizable property of a textarea.

Currently, I can resize a textarea by clicking on the bottom right corner of the textarea and dragging the mouse. How can I disable this?

转载于:https://stackoverflow.com/questions/5235142/how-to-disable-resizable-property-of-textarea

  • 写回答

16条回答 默认 最新

  • 斗士狗 2011-03-08 16:17
    关注

    The following CSS rule disables resizing behavior for textarea elements:

    textarea {
      resize: none;
    }
    

    To disable it for some (but not all) textareas, there are a couple of options.

    To disable a specific textarea with the name attribute set to foo (i.e., <textarea name="foo"></textarea>):

    textarea[name=foo] {
      resize: none;
    }
    

    Or, using an id attribute (i.e., <textarea id="foo"></textarea>):

    #foo {
      resize: none;
    }
    

    The W3C page lists possible values for resizing restrictions: none, both, horizontal, vertical, and inherit:

    textarea {
      resize: vertical; /* user can resize vertically, but width is fixed */
    }
    

    Review a decent compatibility page to see what browsers currently support this feature. As Jon Hulka has commented, the dimensions can be further restrained in CSS using max-width, max-height, min-width, and min-height.

    Super important to know:

    This property does nothing unless the overflow property is something other than visible, which is the default for most elements. So generally to use this, you'll have to set something like overflow: scroll;

    Quote by Chris Coyier, http://css-tricks.com/almanac/properties/r/resize/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(15条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题