textarea 的高度与 Firefox 中的行不匹配 [英] Height of textarea does not match the rows in Firefox

查看:24
本文介绍了textarea 的高度与 Firefox 中的行不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

textarea 的 rows 属性与 Firefox 中的行数不匹配.例如:

The textarea's rows attribute does not match the number of lines in Firefox. For instance:

<textarea rows=4 cols=40>
1
2
3
4
this line is visible in FF
</textarea>

示例:http://jsfiddle.net/Z7zXs/6/

我该如何解决这个问题?rows=4 的 textarea 应该只显示 4 行(而不是 5 行).

How can I fix this issue? The textarea should only display 4 lines (instead of 5) for rows=4.

推荐答案

Firefox 总是在文本字段后添加一行.如果您希望它具有恒定的高度,请使用 CSS,例如:

Firefox always adds an extra line after the textfield. If you want it to have a constant height, use CSS, e.g.:

textarea {
    height: 5em;
}

http://jsfiddle.net/Z7zXs/7/

您还可以使用 @-moz-document url-prefix仅针对 Firefox 浏览器的 CSS 扩展.示例

You can also use the @-moz-document url-prefix CSS extension to target only the Firefox browser. Example

@-moz-document url-prefix() {
    textarea {
        height: 5em;
    }
}

这篇关于textarea 的高度与 Firefox 中的行不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆