<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="root">
<div id="center">
<div class="transform1">
<div style="display: inline-block; background-color: red; width: 400px; height: 200px; transform: translate3d(-200px, -100px, 0)"></div>
</div>
<div class="transform2">
<div style="display: inline-block; background-color: green; width: 400px; height: 200px; transform: translate3d(-400px, -100px, 0)"></div>
</div>
<div class="transform2">
<iframe style="transform: translate3d(0, -100px, 0)" width="400" height="200" src="https://www.youtube.com/embed/aMDFhjpMTEY" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
</div>
<style>
#root {
position:relative;
perspective: 400px;
height:800px;
overflow:hidden;
}
#center {
transform-style:preserve-3d;
transform:translate3d(50%, 50%, 0);
height:100%;
}
#center >* {
position:absolute;
}
.transform1 {
transform-style:preserve-3d;
transform:translate3d(0, 0, 200px);
}
.transform2 {
transform-style:preserve-3d;
transform:translate3d(0, 0, 100px);
}
</style>
</body>
</html>
I believe that the div and iframe in transform2 should function similarly. Here is an example of how they should look.
https://i.sstatic.net/5pgYt.png
However, the result I am seeing looks like this:
https://i.sstatic.net/a5ttk.png
The iframe seems to be ignoring the Z order determined by CSS 3D transforms, even between iframes. Why are they ignoring the Z order? How can this be fixed?