Skip to content

Instantly share code, notes, and snippets.

@jdanyow
Last active February 6, 2021 21:01
Show Gist options
  • Save jdanyow/9916d77f09089f8c6f7993438f8c292a to your computer and use it in GitHub Desktop.
Save jdanyow/9916d77f09089f8c6f7993438f8c292a to your computer and use it in GitHub Desktop.
color-scheme breaks iframe transparency
<!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