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 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导
  • ¥15 docker模式webrtc-streamer 无法播放公网rtsp