Created
March 26, 2021 18:56
-
-
Save FreshLondon/a6df65056b3a6b69891f76c53ef5ca1f to your computer and use it in GitHub Desktop.
This file contains 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 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