Created
March 11, 2020 23:39
-
-
Save easrng/b324c930ea8646eac8fc0dac56e564d6 to your computer and use it in GitHub Desktop.
A polyfill for font-family: system-ui; in CSS
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
(() => { | |
let div = document.createElement("div"); | |
div.style.font = "menu" | |
document.body.appendChild(div) | |
let font = (getComputedStyle(div).fontFamily) | |
div.remove() | |
div = null; | |
let sele = document.createElement("style"); | |
sele.textContent = `@font-face { | |
font-family: 'system-ui'; | |
src: local('${font}'); | |
}`; | |
document.body.appendChild(sele) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment