【发布时间】:2014-05-02 12:38:02
【问题描述】:
问题
我试图让一个图层看起来像是一堵倒塌的墙,露出它后面的图层。我已经设置了两个固定的 div 位置。 “Wall” div 的 z-index 为 9999,“Background” div 的 z-index 为 0;
在我测试过的 Webkit 浏览器 (Safari/IOS) 中,似乎一旦动画在“墙”上开始,z-indexes 就会丢失或被忽略,导致“墙”层突然消失在背景div。
关于如何保留图层的 z 索引有什么想法吗?提前致谢!
示例代码 (注意:jsFiddle 在底部)
HTML 代码
<div id="wall">
This is the wall
</div>
<div id="background">
This is the background
</div>
<button id="start" style="float: right;">
Flip Down
</button>
一些用于启用按钮的 javascript
$('#start').click(function(){
alert('Should Fall Down like a wall, revealing the background');
$('#wall').addClass('animated flipDown');
});
CSS 代码(抄自 animate.css)
#wall{
background-color: #F00;
width: 100px;
height: 100px;
position:fixed;
top:0;
left:0;
z-index: 9999;
}
#background{
background-color: #00F;
width: 100px;
height: 100px;
position:fixed;
top:0;
left:0;
z-index: 0;
}
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
/*** flipDown ***/
@-webkit-keyframes flipDown {
0% {
-webkit-transform: perspective(400px) rotateX(0deg);
transform: perspective(400px) rotateX(0deg);
-webkit-transform-style: flat;
opacity: 1;
}
100% {
-webkit-transform: perspective(400px) rotateX(90deg);
transform: perspective(400px) rotateX(90deg);
-webkit-transform-style: flat;
opacity: 1;
}
}
@keyframes flipDown {
0% {
-webkit-transform: perspective(400px) rotateX(0deg);
-ms-transform: perspective(400px) rotateX(0deg);
transform: perspective(400px) rotateX(0deg);
opacity: 1;
}
100% {
-webkit-transform: perspective(400px) rotateX(90deg);
-ms-transform: perspective(400px) rotateX(90deg);
transform: perspective(400px) rotateX(90deg);
opacity: 0;
}
}
.flipDown {
-webkit-animation-name: flipDown;
animation-name: flipDown;
-webkit-backface-visibility: visible !important;
-ms-backface-visibility: visible !important;
backface-visibility: visible !important;
-webkit-transform-origin: bottom;
-ms-transform-origin: bottom;
transform-origin: bottom;
}
jsFiddle
查看 Safari 与 Chrome 的差异。
【问题讨论】:
-
嗯,我在转换时遇到了类似的问题,但是当我切换到使用动画时,它起作用了