CSS3 3d 变换 - 对于 webkit 浏览器,具有不同 z 索引的重叠 div 会产生不同的结果

发布于 2024-12-21 17:04:35 字数 255 浏览 3 评论 0原文

我试图找出哪个浏览器没有实现此权利:我有 2 个 div 彼此叠置。对于前一个,我旋转 Y 轴并平移 X 轴。现在,对于同一个,我设置了比另一个更低的 z-index。我看到 Chrome / Safari 有 2 个不同的输出。哪一个更有意义。这是我的测试: http://jsfiddle.net/f5VWN/

我想问题可以简化为:给定 3d 空间中的 2 个元素, z 是否-索引很重要:)?

I am trying to figure out which browser is not implementing this right: I have 2 divs positioned on top of each other. For the front one I rotate the Y axis and translate the X axis. Now for this same one I set a lower z-index than the other one. I see 2 different outputs for Chrome / Safari. Which one is the one that makes more sense. Here's my test:
http://jsfiddle.net/f5VWN/

I guess the problem can be shortened to: Given 2 elements in 3d space, does the z-index matters at all :) ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉南桥 2024-12-28 17:04:35

根据规范

变换后的元素在 Z 轴上的位置不影响
堆叠上下文中的顺序。

Safari 渲染不正确。然而,无论如何,我不会让你的布局依赖于这种技术。

According to the spec:

The position on the Z axis of a transformed element does not affect
the order within a stacking context.

Safari is rendering it incorrectly. However, regardless, I would not make your layout depend on this technique.

寂寞美少年 2024-12-28 17:04:35

默认情况下,元素的后代会平铺到父级平面中,因此前后 div 不会共享相同的 3D 空间。它们只是被转换并分别放置在容器 div 的顶部,这会导致后面的 div 绘制在前面的 div 的顶部。要在同一 3D 空间中转换元素,为子 div 提供 3D 重叠,请将容器中的 -webkit-transform-style 属性设置为 preserve-3d:< a href="http://jsfiddle.net/f5VWN/2/" rel="nofollow">http://jsfiddle.net/f5VWN/2/

z-index 仍然很重要,特别是当两者元素重叠 彼此。

Descendants of an element are flattened into the parent's plane by default, so the front and back divs aren't sharing the same 3D space. They're just transformed and laid on top of the container div separately, which causes the back div to be drawn on top of the front div. To transform the elements in the same 3D space, giving 3D overlapping to the child divs, set the -webkit-transform-style property to preserve-3d in the container: http://jsfiddle.net/f5VWN/2/

The z-index still matters, particularly when the two elements overlap each other.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文