Created
September 28, 2018 13:02
-
-
Save vitkon/1bcdc685ee9a540ca383cb5160299694 to your computer and use it in GitHub Desktop.
fluid typography
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
/* Fluid typography with 16-24px font size range based on the width of the viewport */ | |
/* reference - https://css-tricks.com/snippets/css/fluid-typography/ */ | |
:root { | |
--min-content-width: 320; | |
--max-content-width: 1600; | |
--min-font-size: 16; | |
--max-font-size: 24; | |
} | |
body { | |
font-size: 1rem; | |
@media screen and (min-width: 20em) { | |
font-size: calc( | |
var(--min-font-size) * 1px + (var(--max-font-size) - var(--min-font-size)) * | |
(100vw - var(--min-content-width) * 1px) / | |
(var(--max-content-width) - var(--min-content-width)) | |
); | |
} | |
@media screen and (min-width: 70em) { | |
font-size: 1.375rem; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment