【问题标题】:HTML: one row of <textarea> is of how much height?HTML:一行 <textarea> 的高度是多少?
【发布时间】:2013-07-02 18:37:13
【问题描述】:

我想知道一排textarea>的高度。我想知道,因为我想做一些计算。

我们知道还是必须编写一些脚本?

【问题讨论】:

  • 如果你只是想知道有多少行,只需分别用\r\n\r\n分割即可。

标签: html height textarea row row-height


【解决方案1】:

您还可以使用currentStylegetComputedStyle 来确定@​​987654323@(或任何样式)的值,按照获取div 的行高

https://stackoverflow.com/a/4392968/142714

如果你有 jQuery,你可以使用.css(),它抽象了上述内容(需要考虑浏览器差异)。

【讨论】:

    【解决方案2】:

    行高由line-height设置。

    例如:

    <textarea rows="1">hello world</textarea>
    

    如果您设置以下内容:

    textarea { line-height: 1; font-size: 12px; border: none; margin: 0; padding: 0; }
    

    通过检查 textarea 元素,您会发现它的高度为 12px。

    【讨论】:

      【解决方案3】:

      基本上它与line-height 的设置相同。您可以明确设置它,也可以弄清楚它的设置,然后从那里开始。

      Here is an example

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-09-22
        • 2010-10-02
        • 1970-01-01
        • 2015-11-25
        • 1970-01-01
        • 1970-01-01
        • 2010-10-10
        • 1970-01-01
        相关资源
        最近更新 更多