Created
May 13, 2020 19:15
-
-
Save chaance/87dee01f6354a6d8d7a346accd24ffaa to your computer and use it in GitHub Desktop.
Example of scaled relative font sizes
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
:root { | |
/* smallest screens */ | |
--line-height: 1.2; | |
--font-size: 13px; | |
--rhythm: calc(var(--line-height) * var(--font-size)); | |
} | |
/* larger phones */ | |
@media screen and (min-width: 400px) { | |
html { | |
--font-size: 14px; | |
} | |
} | |
/* tablets */ | |
@media screen and (min-width: 640px) { | |
html { | |
--font-size: 16px; | |
--line-height: 1.5; | |
} | |
} | |
/* desktops */ | |
@media screen and (min-width: 1100px) { | |
html { | |
--font-size: 18px; | |
} | |
} | |
/* big-ole screens */ | |
@media screen and (min-width: 1600px) { | |
html { | |
--font-size: 20px; | |
} | |
} | |
html { | |
font-size: var(--font-size); | |
} | |
li, | |
p { | |
font-size: 1rem; | |
line-height: var(--line-height); | |
margin: var(--rhythm) 0; | |
} | |
h1 { | |
font-size: 2rem; | |
line-height: var(--line-height); | |
margin: 1em 0; | |
} | |
h2 { | |
font-size: 1.75rem; | |
line-height: var(--line-height); | |
margin: 1em 0; | |
} | |
h3 { | |
font-size: 1.5rem; | |
line-height: var(--line-height); | |
margin: 1em 0; | |
} | |
h4 { | |
font-size: 1.125rem; | |
line-height: var(--line-height); | |
margin: 0.5em 0; | |
} | |
h5, h6 { | |
font-size: 1rem; | |
line-height: var(--line-height); | |
margin: 0.5em 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment