简体   繁体   English

CSS3变换旋转打破布局和堆叠顺序,取代z-index

[英]CSS3 transform rotate breaks layout and stacking order, superseding z-index

I am designing an html5 mobile application that has an overlay that appears at various points in the app. 我正在设计一个html5移动应用程序,它有一个叠加层,出现在应用程序的不同位置。 The overlay may be at the top of the z index visually, but interactively, it sites behind a div below that is intercepting clicks intended for the overlay. 叠加层可以在视觉上位于z索引的顶部,但是交互式地,它位于下方的div后面,即拦截用于叠加层的点击。 I think I know why it is occurring (CSS stacking context for an element below) but I don't know how to work around it. 我想我知道它为什么会发生(下面一个元素的CSS堆栈上下文),但我不知道如何解决它。

在此输入图像描述

This issue is very similar to this prior question but the resolutions don't seem to apply in this instance. 这个问题与之前的问题非常相似,但这些决议在这种情况下似乎并不适用。 Stacking context has never messed with me before I started applying CSS3 animations and transforms to my layouts. 在我开始应用CSS3动画并转换到我的布局之前,堆栈上下文从未搞砸过我。 Now I am a mess. 现在我一团糟。

So far I have tried transform-style: flat; 到目前为止,我尝试过transform-style: flat; -webkit-transform: translateZ(0px); -webkit-transform: translate3d(0,0,0); and a thousand different z-index approaches to try and keep the lower z-index elements from blocking clicks intended for the overlay. 以及一千种不同的z-index方法,试图阻止较低的z-index元素阻止用于覆盖的点击。 I am at a loss and could use some outside perspective. 我不知所措,可以使用一些外部视角。

I have a codepen that illustrates the issue perfectly here . 我有一个codepen,在这里完美地说明了这个问题

If you use a translate3D in z to move your content back, it now works. 如果您使用z中的translate3D来移回您的内容,它现在可以使用了。 Chang your div2 style to this: 张你的div2风格到这个:

    -webkit-transform: translate3D(0px,0px,-1px) rotateX(180deg);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM