Skip to content

Instantly share code, notes, and snippets.

@mklickman
Last active December 29, 2015 17:59
Show Gist options
  • Save mklickman/7707408 to your computer and use it in GitHub Desktop.
Save mklickman/7707408 to your computer and use it in GitHub Desktop.
Updates font size of input text to make it fit the entire field instead of overflowing. May need some tweaking to be entirely portable.
$('input[type="text"]').bind("propertychange keyup input paste", function(event){
var len = $(this).val().length;
if (len >= 13){
letters = len - 13;
percentage = letters/34;
fontsize = Math.round(57-45*percentage);
console.log(fontsize);
console.log(len);
if (fontsize < 18) fontsize = 18;
$('.subscribeInput').css('font-size',fontsize+"px")
} else {
$('.subscribeInput').css('font-size','57px');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment