Skip to content

Instantly share code, notes, and snippets.

@bittu
Created December 17, 2019 13:59
Show Gist options
  • Save bittu/1d5ed931e96fb55303f487c5b2e2f349 to your computer and use it in GitHub Desktop.
Save bittu/1d5ed931e96fb55303f487c5b2e2f349 to your computer and use it in GitHub Desktop.
Count number of lines displayed in an element
export const countNumOfLines = (el) => (el ? Math.ceil(el.clientHeight / parseInt(getComputedStyle(el, null).getPropertyValue('line-height'))) : 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment