Skip to content

Commit

Permalink
Explicitly set the padding of the textarea to 0
Browse files Browse the repository at this point in the history
If textareas are styled to have a width of 100%, as well as a non-zero padding, the "invisible" textarea inserted by autosize.js will increase the width of the page by the amount of the padding, resulting in a horizontal scrollbar.

This may seem like an edge case, but the popular CSS framework Foundation sets those properties by default as part of their form styling.

The fix is to explicitly set the padding of the invisible textarea to 0. I have tested this on my site and it solves the issue without affecting autosize's functionality.
  • Loading branch information
nickbaum committed Aug 27, 2013
1 parent d15d534 commit 7146df0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion jquery.autosize.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},

// border:0 is unnecessary, but avoids a bug in FireFox on OSX
copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',
copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',

// line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
typographyStyles = [
Expand Down

0 comments on commit 7146df0

Please sign in to comment.