Last active
August 14, 2024 14:36
-
-
Save colingourlay/d95908ec5cd4854c7a5afa06f3989479 to your computer and use it in GitHub Desktop.
Support Apple's dynamic text sizing in web content (iOS Safari & WebViews)
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
/* | |
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