How can I prevent the textarea from stretching beyond his parent DIV element? (google-chrome issue only)

前端 未结 4 1966
南方客
南方客 2020-12-12 16:37

How can I prevent the textarea from stretching beyond its parent DIV element?

I have this textarea inside a table which is inside a DIV and it seems that it causes t

4条回答
  •  孤城傲影
    2020-12-12 17:20

    Textarea resize control is available via the CSS3 resize property:

    textarea { resize: both; } /* none|horizontal|vertical|both */
    textarea.resize-vertical{ resize: vertical; }
    textarea.resize-none { resize: none; }
    

    Allowable values self-explanatory: none (disables textarea resizing), both, vertical and horizontal.

    Notice that in Chrome, Firefox and Safari the default is both.

    If you want to constrain the width and height of the textarea element, that's not a problem: these browsers also respect max-height, max-width, min-height, and min-width CSS properties to provide resizing within certain proportions.

    Code example:

    #textarea-wrapper {
      padding: 10px;
      background-color: #f4f4f4;
      width: 300px;
    }
    
    #textarea-wrapper textarea {
      min-height:50px;
      max-height:120px;
      width: 290px;
    }
    
    #textarea-wrapper textarea.vertical { 
      resize: vertical;
    }

提交回复
热议问题