Skip to content

Instantly share code, notes, and snippets.

@acenkus
Forked from brianblakely/rem-calibrate.css
Created December 11, 2015 07:29
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 acenkus/f02616562453e88c5273 to your computer and use it in GitHub Desktop.
Save acenkus/f02616562453e88c5273 to your computer and use it in GitHub Desktop.
Simulate vw with rems
/* Android stock browser won't let you set font-size smaller than 8px unless you apply this. */
:root {
-webkit-text-size-adjust: none;
-moz-text-size-adjust: none;
-ms-text-size-adjust: none;
-o-text-size-adjust: none;
text-size-adjust: none;
}
/*
Place this within a <script> in your <head>, prior to your stylesheet
Then use rems instead of px globally - your site will scale 1:1 with viewport width
*/
function remCalibrate() {
document.documentElement.style.fontSize = window.innerWidth/100 + 'px';
}
remCalibrate();
window.addEventListener('resize', remCalibrate, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment