It is possible to expand a textarea only with CSS?

前端 未结 5 735
轮回少年
轮回少年 2020-11-29 01:48

I have a textarea with 200px of height, but when I pass that 200px with text I want to have the textarea expanded instead of keeping the 200px of height with a scroll bar.

5条回答
  •  执念已碎
    2020-11-29 02:15

    It is possible to make a textarea expandable by the user, using just CSS. In fact, in some modern browsers, such expandability is even the browser default. You can explicitly ask for it:

    textarea { resize: both; }
    

    Browser support is growing but is still limited.

    There is typically just a small hint about resizability: a resize handle in the lower right corner. And I’m afraid most users won’t understand this hint.

    You cannot make a textarea expand automatically by content using just CSS.

提交回复
热议问题