知识在于积累(.NET之路……)

导航

让textarea自动调整大小的实现方法

<!doctype html>
<html>
<head>
<title>自动调整大小的textarea </title>
<meta charset = "utf-8" />
<style type = "text/css">
.editable
{cursor:text; font-size:13px; color:#003366;width:80px;line-height:20px;height:20px;font-family:Arial;cursor:text;*overflow-y:hidden; }
</style>
</head>
<body>
<textarea class='editable' onkeydown ="if(event.keyCode==13) return false; " oninput="this.style.height='0px';this.style.height=(this.scrollHeight+'px');" onpropertychange="this.style.height=(this.scrollHeight+'px')" /></textarea>
</body>
</html>

posted on 2011-05-17 16:21  汤尼  阅读(1020)  评论(0编辑  收藏  举报