由于输入框我想不到有什么方法能监听换行再赋值高度,所以我就用了这个插件弄了,还是挺香的~~先看图
// 输入框的样式
.animated {
padding: .2rem .2rem 0 .2rem;
border-radius: .1rem;
background: #f5f5f5;
vertical-align: top;
flex: 1;
max-height: 1.6rem;
line-height: .36rem;
resize: none;
}
<textarea class='animated' style="margin-bottom: .2rem" placeholder="请加入交流学习吧"></textarea>
<script src="../js/jquery.autosize.js"></script>
<script>
$(function(){
$('.animated').autosize();
});
</script>
[附上下载链接](https://github.com/acdvorak/jquery.autosize)