Created
December 30, 2017 17:23
-
-
Save dejurin/9bef02be6876e068ee276bee31cb3bcb to your computer and use it in GitHub Desktop.
Resize font depending on string length
This file contains 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
var fontFitResize = function(fit, wrap, step = 0.5) { | |
var currentSize; | |
while(fit.offsetWidth < wrap.offsetWidth) { | |
currentSize = parseFloat(window.getComputedStyle(wrap, null).getPropertyValue('font-size')); | |
wrap.style.fontSize = (currentSize - step) + 'px'; | |
console.log(wrap.style.fontSize); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment