It is possible to expand a textarea only with CSS?

前端 未结 5 743
轮回少年
轮回少年 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:30

    No it is not possible to do only with css, but you could use jquery:

    $('#your_textarea').on('keydown', function(e){
        var that = $(this);
        if (that.scrollTop()) {
            $(this).height(function(i,h){
                return h + 20;
            });
        }
    });
    

提交回复
热议问题