-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
textarea如何实现高度自适应 #112
Comments
1.方法一:利用JS控制
|
2.方法二:div模拟textarea文本
HTML代码:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
今天需要些一个回复评论的页面,设计师给的初始界面就是一个只有一行的框。然后当时就想这个交互该怎么实现比较好,然后想起了新浪微博的做法:点击评论,默认显示一行,当输入的文字超过一行或者输入Enter时,输入框的高度会随着改变,直到输入完毕。顿时觉得这个细节做得挺不错的,可以效仿下。下面分享2种实现textarea高度自适应的做法,一种是利用JS控制的(因为存在浏览器兼容问题,所以写起来比较麻烦);另一种是用div来模拟textarea来实现的,用CSS控制样式,不用JS;
The text was updated successfully, but these errors were encountered: