Created
December 19, 2018 17:28
-
-
Save bitsmanent/e4f71b5ad4c1b1a5042b5a759e8d86e2 to your computer and use it in GitHub Desktop.
Compute full height of an element
This file contains hidden or 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
function getheight(el) { | |
var props = ["height", "marginTop", "marginBottom", "borderTop"]; | |
var s = getComputedStyle(el), ret = 0; | |
if(!s) return 0; | |
props.forEach((p) => ret += parseFloat(s[p])); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment