【发布时间】:2020-01-10 16:08:16
【问题描述】:
参考此示例: https://codepen.io/jyloo/pen/KKwoLKB
我注意到,当我将动画填充模式设置为前进的动画容器时,其中的绝对定位子元素(弹出窗口)未按预期显示,并且似乎它们的 z-index 被忽略了。
我的动画:
.animate {
animation-direction: reverse;
}
.animate.animate--from-bottom {
opacity: 0;
animation: from-bottom 0.3s ease-out;
animation-fill-mode: forwards;
}
@keyframes from-bottom {
0% {transform: translateY(80px);opacity:0;}
100% {transform: translateY(0px);opacity:1;}
}
我的孩子元素(弹出)
.popup {
z-index: 10;
position: absolute;
background: white;
padding: 0 1rem;
box-shadow: 2px 2px 5px 5px rgba(0,0,0,0.1);
width: calc(300px - 2rem);
}
如果我删除动画填充模式,子元素会显示得很好。
任何人都可以帮助我理解这种行为和解决方法,以便我的子元素(弹出窗口)可以在找到动画父元素下工作。
【问题讨论】:
-
定位的 div 和“Hello World”的 div 具有不同的堆叠上下文。
标签: css css-animations