Skip to content

Instantly share code, notes, and snippets.

@SteveBarnett
Last active September 24, 2016 04:49
Show Gist options
  • Save SteveBarnett/8d9dcfdda4e53a2d1b858e17284a0fc7 to your computer and use it in GitHub Desktop.
Save SteveBarnett/8d9dcfdda4e53a2d1b858e17284a0fc7 to your computer and use it in GitHub Desktop.
Loading a web font nicely, with FOUT
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