Last active
August 30, 2022 00:46
-
-
Save Calvein/8513814 to your computer and use it in GitHub Desktop.
Change font-size of an element if text is bigger than the content.
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
// Resize el if too long | |
fontSize = parseInt(el.style.fontSize) | |
while (el.offsetWidth < el.scrollWidth) | |
el.style.fontSize = --fontSize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment