csdnceshi62 2011-03-08 16:15 采纳率: 100%
浏览 263
已采纳

如何禁用 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 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题