HTML网页中textarea的高度自适应怎么实现

HTML网页中textarea的高度自适应怎么实现,第1张

可以通过js去写,求采纳

$fnautoTextarea = function (options){  

    var defaults = {  

        maxHeight:null,  

        minHeight:$(this)height(),

    };  

    var opts = $extend({}, defaults, options);  

    return $(this)each(function (){  

        var _this = $(this);  

        _thisbind('paste cur keydown keyup focus blur', function (){  

            var height, style = thisstyle;  

            styleheight = optsminHeight + 'px';  

            if(thisscrollHeight > optsminHeight){  

                if(optsmaxHeight && thisscrollHeight > optsmaxHeight){  

                    height = optsmaxHeight;  

                    styleoverflowY = 'scroll';  

                }else{  

                    height = thisscrollHeight;  

                    styleoverflowY = 'hidden';  

                }  

                styleheight = height + 'px';  

            }  

        });  

    });  

}  

$(function(){

$('textarea')autoTextarea({maxHeight:400});

});

extarea文本域轻松实现高度自适应

demo演示地址:>

wxml文件内容

fixed='true' 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true

contenteditable="true" 是否自动增高,设置auto-height时,styleheight不生效

placeholder-style 指定 placeholder 的样式

placeholder 输入框为空时占位符

wxss文件内容

以上就是关于HTML网页中textarea的高度自适应怎么实现全部的内容,包括:HTML网页中textarea的高度自适应怎么实现、如何让textarea的高度自适应、微信小程序textArea输入框随着输入字数自适应高度等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9469224.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-28
下一篇2023-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存