Skip to content

Instantly share code, notes, and snippets.

@FreshLondon
Created March 26, 2021 18:56
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 FreshLondon/a6df65056b3a6b69891f76c53ef5ca1f to your computer and use it in GitHub Desktop.
Save FreshLondon/a6df65056b3a6b69891f76c53ef5ca1f to your computer and use it in GitHub Desktop.
function toREM (size = 1) {
let winWidth = jQuery(window).width();
if (winWidth <= 991) {
//base font size at 750px is 22px.
let baseFontSizeSmall = 29.1;
let winPercentSmall = winWidth / 991;
let fontSizeSmallFinal = window.finalFont = (baseFontSizeSmall * winPercentSmall);
return size / fontSizeSmallFinal;
} else {
//base font size at 1920px is 16px.
let baseFontSizeLarge = 16;
let winPercent = winWidth / 1920;
let fontSizeLargeFinal = window.finalFont = (baseFontSizeLarge * winPercent);
return size / fontSizeLargeFinal;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment