Skip to content
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

[html] 第137天 如何让textarea高度自适应呢? #1132

Open
haizhilin2013 opened this issue Aug 30, 2019 · 4 comments
Open

[html] 第137天 如何让textarea高度自适应呢? #1132

haizhilin2013 opened this issue Aug 30, 2019 · 4 comments
Labels
html html

Comments

@haizhilin2013
Copy link
Collaborator

第137天 如何让textarea高度自适应呢?

@haizhilin2013 haizhilin2013 added the html html label Aug 30, 2019
@LinStan
Copy link

LinStan commented Aug 31, 2019

使用div的contenteditable属性模拟textarea,通过设定min-height 然后用高度慢慢撑高区域。

@dragon8github
Copy link

使用 div contenteditable 模拟的代价实在太大了。

推荐看看 ant-design 和 elementUI 的源码设计即可。

https://github.com/ElemeFE/element/blob/dev/packages/input/src/calcTextareaHeight.js#L73

https://github.com/ant-design/ant-design/blob/master/components/input/calculateNodeHeight.tsx#L88

@whitesky1225
Copy link

用UI框架用习惯了,能想到的就是看框架源码。。

@tao7544
Copy link

tao7544 commented Oct 10, 2019

监听 input 事件,元素高度 = 元素可滚动高度

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
html html
Projects
None yet
Development

No branches or pull requests

5 participants