斗士狗 2011-03-08 16:15 采纳率: 0%
浏览 273
已采纳

如何禁用 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

  • 写回答

13条回答 默认 最新

  • YaoRaoLov 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/

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

报告相同问题?

悬赏问题

  • ¥15 使用yolov5-7.0目标检测报错
  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备