Last active
February 6, 2021 21:01
-
-
Save jdanyow/9916d77f09089f8c6f7993438f8c292a to your computer and use it in GitHub Desktop.
color-scheme breaks iframe transparency
This file contains 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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<!-- this breaks iframe transparency: --> | |
<meta name="color-scheme" content="light dark"> | |
<!-- remove the line above and the iframe background becomes transparent as expected --> | |
<title>Demo</title> | |
</head> | |
<body style="background-color: green"> | |
<h1>Hello world!</h1> | |
<iframe></iframe> | |
<script> | |
const fdoc = document.querySelector('iframe').contentWindow.document; | |
fdoc.head.innerHTML = ` | |
<style> | |
html,body { background-color: transparent; } | |
</style> | |
`; | |
fdoc.body.innerHTML = ` | |
<h1>Hello world!</h1> | |
`; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment