【问题标题】:Auto resize textarea diagonally to fit content自动调整文本区域的对角线大小以适应内容
【发布时间】:2015-02-27 13:03:43
【问题描述】:

我想自动调整文本区域的对角线大小以适应内容。

我看到了一个 jsfiddle 演示,但那里的 textarea 只是按高度调整大小。是否可以自动调整对角线大小?

【问题讨论】:

标签: javascript jquery html


【解决方案1】:

试试这个方法

 txt.on('keyup', function () {

        content = $(this).val();

        content = content.replace(/\n/g, '<br>');
        hiddenDiv.html(content + '<br class="lbr">');

        $(this).css('height', hiddenDiv.height()+50);
        $(this).css('width', $(this).width()+50);
    });

【讨论】:

  • 不,它不起作用。这是异常增加宽度。我需要对角线自动调整它的大小。就像使用纵横比一样。
猜你喜欢
  • 2021-10-31
  • 1970-01-01
  • 1970-01-01
  • 2020-04-14
  • 2011-12-24
  • 1970-01-01
  • 2014-07-02
  • 2020-12-10
相关资源
最近更新 更多