Last active
December 29, 2015 17:59
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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