Skip to content

Instantly share code, notes, and snippets.

@wad3g
Created September 8, 2016 01:46
Show Gist options
  • Save wad3g/05a838ac771bb962c34ffc9f66c1ed9b to your computer and use it in GitHub Desktop.
Save wad3g/05a838ac771bb962c34ffc9f66c1ed9b to your computer and use it in GitHub Desktop.
Adjust font-size based on viewport height and width
/* The type font size in a responsive layout should be able to adjust with each viewport.
You can calculate the font size based on the viewport height and width using :root */
:root {
font-size: calc(1vw + 1vh + .5vmin);
}
/* Now you can utilize the root em unit based on the value calculated by :root */
body {
font: 1em/1.6rem sans-serif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment