Skip to content

Instantly share code, notes, and snippets.

@Calvein
Last active August 30, 2022 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Calvein/8513814 to your computer and use it in GitHub Desktop.
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.
// 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