Last active
August 1, 2018 19:35
-
-
Save udovichenko/c55185efd4d08f1ad0299c02bd309a69 to your computer and use it in GitHub Desktop.
Calculation of mixed font-size: calc(px + vw) by two breakpoint values
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
var w1 = 360; // first breakpoint window width | |
var w2 = 1920; // second breakpoint window width | |
var fz1 = 20; // first breakpoint required font-size | |
var fz2 = 55; // second breakpoint required font-size | |
var px, vw; | |
vw = (fz1 - fz2) / (w1 - w2); | |
px = parseInt(fz2 - w2 * vw); | |
vw *= 100; | |
vw = vw.toFixed(1); | |
console.log('calc(' + px + 'px + ' + vw + 'vw)'); // calc(32px + 2.2vw) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment