Skip to content

Instantly share code, notes, and snippets.

@a9
Created June 28, 2016 07:04
Show Gist options
  • Save a9/c8db23fa836cffb40a1748650a7bdfe7 to your computer and use it in GitHub Desktop.
Save a9/c8db23fa836cffb40a1748650a7bdfe7 to your computer and use it in GitHub Desktop.
function countLines(ele) {
var styles = window.getComputedStyle(ele, null);
var lh = parseInt(styles.lineHeight, 10);
var h = parseInt(styles.height, 10);
var lc = Math.round(h / lh);
console.log('line count:', lc, 'line-height:', lh, 'height:', h);
return lc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment