textarea内容自动撑开高度,实现高度自适应
封面图
•
2023-07-17
•
Html/Css
220
0
0
0
方法一: ```html <textarea rows="1" oninput="resize(this)"></textarea> <script> function resize(obj) { obj.style.height = "1px"; obj.style.height = obj.scrollHeight + "px"; } </script> ``` 方法二: ```html <textarea rows="1" oninput="resize(this)" onpropertychange="resize(this)"></textarea> <script> function resize(obj) { obj.style.height = "auto"; obj.style.height = obj.scrollHeight + "px"; } </script> ```
上一篇:
CSS 实现自动换行、强制换行、强制不换行的属性
下一篇:
html中的空格符号( nbsp; ensp; emsp; )介绍以及中文对齐实现的方法
标题录入,一次不能超过6条
返回顶部
留言
留言
评论