Turn off textarea resizing

前端 未结 8 1532
暗喜
暗喜 2021-01-30 03:51

I\'m trying to turn off textarea resizing in my site; right now I\'m using this method:

.textarea {
    clear:left;
    min-width: 267px;
    max-width: 267px;
          


        
相关标签:
8条回答
  • 2021-01-30 04:04

    This is works for me

    <textarea
      type='text'
      style="resize: none"
    >
    Some text
    </textarea>

    0 讨论(0)
  • 2021-01-30 04:07

    It can done easy by just using html draggable attribute

    <textarea name="mytextarea" draggable="false"></textarea>
    

    Default value is true.

    0 讨论(0)
  • 2021-01-30 04:09

    Try this CSS to disable resizing

    The CSS to disable resizing for all textareas looks like this:

    textarea {
        resize: none;
    }
    

    You could instead just assign it to a single textarea by name (where the textarea HTML is ):

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

    Or by id (where the textarea HTML is ):

    #foo {
        resize: none;
    }
    

    Taken from: http://www.electrictoolbox.com/disable-textarea-resizing-safari-chrome/

    0 讨论(0)
  • 2021-01-30 04:09

    this will do your job

      textarea{
            resize:none;
        }
    

    enter image description here

    0 讨论(0)
  • 2021-01-30 04:12

    CSS3 can solve this problem. Unfortunately it's only supported on 60% of used browsers nowadays.

    For IE and iOS you can't turn off resizing but you can limit the textarea dimension by setting its width and height.

    /* One can also turn on/off specific axis. Defaults to both on. */
    textarea { resize:vertical; } /* none|horizontal|vertical|both */
    

    See Demo

    0 讨论(0)
  • 2021-01-30 04:25

    Just one extra option, if you want to revert the default behaviour for all textareas in the application, you could add the following to your CSS:

    textarea:not([resize="true"]) {
      resize: none !important;
    }
    

    And do the following to enable where you want resizing:

    <textarea resize="true"></textarea>
    

    Have in mind this solution might not work in all browsers you may want to support. You can check the list of support for resize here: http://caniuse.com/#feat=css-resize

    0 讨论(0)
提交回复
热议问题