Last active
September 24, 2016 04:49
-
-
Save SteveBarnett/8d9dcfdda4e53a2d1b858e17284a0fc7 to your computer and use it in GitHub Desktop.
Loading a web font nicely, with FOUT
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
body { | |
// set your base | |
font-family: sans-serif; | |
line-height: 1.25; | |
// .wf-loading means js is running and the webfont is loading, | |
// so adjust the base font to minimise the jank when the switch happens | |
.wf-loading & { | |
font-size: 0.935em; | |
line-height: 2.5; | |
} | |
// when the webfont has loaded, apply it | |
.wf-active & { | |
font-family: "Source Sans Pro", sans-serif; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment