You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.child { transform-origin: top left; transform: rotateX(40deg); background-color: lime; }
480
+
</style>
481
+
482
+
<div class="container">
483
+
<div class="transformed">
484
+
<div class="child"></div>
485
+
</div>
486
+
</div>
471
487
</pre>
472
-
<p>Example of simple 3D rendering context
488
+
<p>This exmaple shows how nested 3D transforms are rendered in the absence of <code>transform-style: preserve-3d</code>. The blue div is transformed as in the previous example, with its rendering influenced by the perspective on its parent element. The lime element also has a 3D transform, which is a rotation about the X axis (anchored at the top, by virtue of the transform-origin). However, the lime element is being rendered into the plane of its parent because it is not a member of a 3D rendering context; the parent is "flattening".
473
489
</p>
474
490
<divclass="figure">
491
+
<imgsrc="examples/3d-rendering-context-flat.png" width="240" height="200" alt="Nested 3D transforms, with flattening">
.child { transform-origin: top left; transform: rotateX(40deg); background-color: lime; }
502
+
</style>
480
503
</pre>
481
-
<p>Example of deeper 3D rendering context
504
+
<p>This example is identical to the previous example, with the addition of <code>transform-style: preserve-3d</code> on the blue element. The blue element now establishes a 3D rendering context, of which the lime element is a member. Now both blue and lime elements share a common three-dimensional space, so the lime element renders as tilting out from its parent, influenced by the perspective on the container.
482
505
</p>
483
506
<divclass="figure">
507
+
<imgsrc="examples/3d-rendering-context-3d.png" width="240" height="200" alt="Nested 3D transforms, with preserve-3d.">
484
508
</div>
485
509
</div>
486
510
487
-
<divclass="example">
511
+
<divclass="example">
488
512
<pre>
513
+
<style>
514
+
.container {
515
+
background-color: rgba(0, 0, 0, 0.3);
516
+
transform-style: preserve-3d;
517
+
perspective: 500px;
518
+
}
519
+
.container > div {
520
+
position: absolute;
521
+
left: 0;
522
+
}
523
+
.container > :first-child {
524
+
transform: rotateY(45deg);
525
+
background-color: orange;
526
+
top: 10px;
527
+
height: 135px;
528
+
}
529
+
.container > :last-child {
530
+
transform: translateZ(40px);
531
+
background-color: rgba(0, 0, 255, 0.75);
532
+
top: 50px;
533
+
height: 100px;
534
+
}
535
+
</style>
536
+
537
+
<div class="container">
538
+
<div></div>
539
+
<div></div>
540
+
</div>
489
541
</pre>
490
-
<p>Example of flattening inside 3D rendering context
491
-
</p>
492
-
<divclass="figure">
542
+
<p>
543
+
This example shows show elements in a 3D rendering context can intersect. The container element establishes
544
+
a 3D rendering context for itself and its two children. The children intersect with eachother, and
545
+
the orange element also intersects with the container.
0 commit comments