研究textarea自适应高度的,发现有些是通过div来模拟的,测试下也还可行。摘抄了一个例子。
<html> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>div模拟textarea实现高度自适应</title> <head> <style> .test_box { width: 400px; min-height: 20px; max-height: 300px; _height: 20px; margin-left: auto; margin-right: auto; padding: 3px; outline: 0; border: 1px solid #a0b3d6; font-size: 18px; word-wrap: break-word; overflow-x: hidden; overflow-y: auto; _overflow-y: visible; } </style> </head> <body> <div contenteditable="true" class="test_box"></div> </body> </html>
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/98523.html