zoukankan      html  css  js  c++  java
  • HTML 特效 自动适应的文本框

        <style type="text/css">
            #shadow, #text { font: 12px/16px Arial;  200px; overflow: hidden; height: 16px; }
            #shadow { position: absolute; border- 0px; padding: 0px; visibility: hidden; }
            #text { resize: none; }
        </style>
        <script type="text/javascript">
            /*
          by VILIC VANE
                Web www.vilic.info
                Email i@vilic.info
            */
            window.onload = function () {
                var text = document.getElementById("text"); //用户看到的文本框
                var shadow = document.getElementById("shadow"); //隐藏的文本框
                text.oninput = //非IE的
                text.onpropertychange = //IE的
                onchange;
                
                function onchange() {
                    shadow.value = text.value;
                    setHeight();
                    setTimeout(setHeight, 0); //针对IE 6/7/8的延迟, 否则有时会有一个字符的出入
                    function setHeight() { text.style.height = shadow.scrollHeight + "px"; }
                }
            };
        </script>
    <body>
        <textarea id="text"></textarea>
        <textarea id="shadow"></textarea>
    </body>
    
  • 相关阅读:
    grep
    [NOI2009]植物大战僵尸
    sed
    YY的GCD
    awk
    CF1100E
    cat
    tac
    [学习笔记]基数排序
    more
  • 原文地址:https://www.cnblogs.com/zcy_soft/p/2153700.html
Copyright © 2011-2022 走看看