文章来源:http://www.cnblogs.com/jice/archive/2011/08/07/2130069.html
HTMLHEADTITLEtextarea宽度、高度自动适应处理方法/TITLE!-- 控制宽度的自动适应 --style type="text/css".comments { width:100%;/*自动适应父布局宽度*/ overflow:auto; word-break:break-all;/*在ie中解决断行问题(防止自动变为在一行显示,主要解决ie兼容问题,ie8中当设宽度为100%时,文本域类容超过一行时,当我们双击文本内容就会自动变为一行显示,所以只能用ie的专有断行属性“word-break或word-wrap”控制其断行)*/}/style/HEADBODYFORM METHOD=POST ACTION= " "!-- 主要控制高度的自动适应 --!-- 第一个是普通textarea --textarea class="comments" rows="10" cols="10" /textarea!-- 以下两种方式都可以解决textarea行高自动适应类容的高度 --textarea class="comments" rows=1 name=s1 cols=27 onpropertychange= "this.style.posHeight=this.scrollHeight "/textareatextarea class="comments" style="height:expression((this.scrollHeight150)?'150px':(this.scrollHeight+5)+'px');overflow:auto;"/textarea /FORM/BODY/HTML













