css - 关闭时模态上的css关键帧动画
问题描述
这是我的模态叠加层和容器的 css
.overlay {
position: fixed;
background-color: rgba(20, 20, 21, 0.5);
top: 0;
left: 0;
right: 0;
bottom: 0;
animation-name: fadeIn;
animation-iteration-count: 1;
animation-fill-mode: forwards;
animation-duration: 350ms;
animation-timing-function: ease-in-out;
}
.container {
background: var(--color-white);
max-height: 94vh;
max-width: 62.5rem;
z-index: 2;
transform: none;
border-radius: 4px;
overflow: hidden;
animation-name: slideUp;
animation-iteration-count: 1;
animation-fill-mode: forwards;
animation-duration: 350ms;
animation-timing-function: var(--animation-sharp);
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(50%);
}
to {
opacity: 1;
transform: translateY(0);
}
}
基本上,覆盖层会淡入,同时容器会向上滑动。目前,当模式打开时,动画按预期工作,但关闭时根本没有动画。如何确保关闭时会有反向动画?所以关闭时,容器会向下滑动,覆盖层会淡出。
解决方案
推荐阅读
- node.js - 猫鼬路径中的值转换为 ObjectID 失败
- objective-c - 如何使用 Xcode 在 Mac OS X 上的 Obj-C 中仅用几行在窗口的画布上绘制/绘制/渲染一个点或着色一个像素?
- c# - 如何在c# windows应用程序中使用sharpshell为文件和文件夹实现图标覆盖
- java - 处理长时间运行的清理逻辑以响应 Netty channelInactive 事件的正确方法?
- sql - 如何设计自定义窗口函数以在pyspark数据框的时间窗口内选择列值
- r - R 中的 system() 函数中的“输入”参数有什么作用?
- typescript - Typescript 断言签名和承诺
- java - 这段代码有什么样的循环错误以及如何修复它?
- macos - macOS:如何使用终端在启动后重定向进程的 STDERR / STDOUT?
- azure - 用于 msticpy QueryProvider 的 Jupypter 笔记本中的 SyntaxError