zoukankan      html  css  js  c++  java
  • textarea文本域宽度和高度(width、height)自动适应变化处理

    <HTML>
    <HEAD>
    <TITLE>textarea宽度、高度自动适应处理方法</TITLE>
    <!-- 控制宽度的自动适应 -->
    <style type="text/css">
    .comments {
     100%;/*自动适应父布局宽度*/
     overflow:auto;
     word-break:break-all;/*在ie中解决断行问题(防止自动变为在一行显示,主要解决ie兼容问题,ie8中当设宽度为100%时,文本域类容超过一行时,当我们双击文本内容就会自动变为一行显示,所以只能用ie的专有断行属性“word-break或word-wrap”控制其断行)*/
    }
    </style>
    </HEAD>

    <BODY>
    <FORM   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 "></textarea>

    <textarea class="comments" style="height:expression((this.scrollHeight>150)?'150px':(this.scrollHeight+5)+'px');overflow:auto;"></textarea> 
    </FORM>
    </BODY>
    </HTML>

  • 相关阅读:
    git 简单操作
    JS中substr与substring的区别
    手写map, filter函数
    node之pipe
    nodejs之child_process
    node真的是单线程模式吗
    【xinsir】分享一个查找文件的脚手架
    【xinsir】函数库,持续更新
    数组循环方法统计
    20190916
  • 原文地址:https://www.cnblogs.com/jice/p/2130069.html
Copyright © 2011-2022 走看看