Skip to content

Instantly share code, notes, and snippets.

@colingourlay
Last active September 16, 2023 15:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colingourlay/d95908ec5cd4854c7a5afa06f3989479 to your computer and use it in GitHub Desktop.
Save colingourlay/d95908ec5cd4854c7a5afa06f3989479 to your computer and use it in GitHub Desktop.
Support Apple's dynamic text sizing in web content (iOS Safari & WebViews)
/*
To support dynamic type in iOS, we need to set Apple's
system font and then define font-families and rem-based
font-sizes on descendant elements:
*/
@supports (font: -apple-system-body) {
html {
font: -apple-system-body;
}
}
body {
font-family: <your_font_family_here>;
}
p {
font-size: 1.25rem;
}
/*
If you've set a custom rem size in px on the html
element, and want to maintain that on non-Apple
devices, the font override muse be !important:
*/
body {
font-size: 20px;
}
@supports (font: -apple-system-body) {
html {
font: -apple-system-body !important;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment