Skip to content

Instantly share code, notes, and snippets.

@jclement
Created December 13, 2013 17:58
Show Gist options
  • Select an option

  • Save jclement/7948373 to your computer and use it in GitHub Desktop.

Select an option

Save jclement/7948373 to your computer and use it in GitHub Desktop.
Firefox automatically adds a "bonus" row to textarea fields making them taller than they should be given the "row=X" attribute on the text area. This is really annoying when you want the textarea to simply be 1 row high and to have it automatically grow, as needed, with jquery-autosize. The following snippet forces a starting height on the contr…
if (navigator.userAgent.toLowerCase().indexOf("firefox") !== -1) {
// Firefox/Mozilla automatically adds a "bonus" row to textareas. Through CSS, force the height back to the number of rows specified before
// autosize sees it.
var height = parseFloat(input.css("line-height")) * opt.rows + parseFloat(input.css("padding-top")) + parseFloat(input.css("padding-bottom"));
input.css("height", height + "px");
}
_.defer(function() {
input.autosize();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment