Created
June 5, 2018 02:05
-
-
Save flier268/07183c6e0a695eab6197447249bf9a7b to your computer and use it in GitHub Desktop.
Get real font-size(Wkhtmltox)
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
<html id="html"> | |
<body> | |
<div style="width:100%" id="ruler"></div> | |
<div style="width:50%"> | |
<p style="font-size:1rem;">This is 1 rem</p> | |
</div> | |
<script> | |
function w3_getStyleValue(elmnt,style) { | |
if (window.getComputedStyle) { | |
return window.getComputedStyle(elmnt,null).getPropertyValue(style); | |
} else { | |
return elmnt.currentStyle[style]; | |
} | |
} | |
var t; | |
var width, height; | |
width = Number(w3_getStyleValue(document.getElementById("ruler"), "width").replace("px", "")).toFixed(); | |
document.getElementById("html").style.fontSize=((595/width)*12)+"pt"; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment