334 lines
7.8 KiB
CSS
334 lines
7.8 KiB
CSS
/* Toast 容器 */
|
|
#toast-stage {
|
|
position: fixed;
|
|
top: 80px;
|
|
right: 24px;
|
|
width: 320px;
|
|
z-index: 9999;
|
|
pointer-events: none;
|
|
}
|
|
|
|
#toast-container {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 400px;
|
|
perspective: 1200px;
|
|
transform-style: preserve-3d;
|
|
}
|
|
|
|
/* Toast 基础 */
|
|
.toast {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
padding: 18px 24px;
|
|
border-radius: 16px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
backdrop-filter: blur(20px) saturate(180%);
|
|
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
|
pointer-events: auto;
|
|
transform-origin: center top;
|
|
will-change: transform, opacity;
|
|
}
|
|
|
|
/* ========== 进入动画状态 ========== */
|
|
.toast.entering {
|
|
opacity: 0;
|
|
transform: translateX(-120px) translateZ(50px) rotateY(25deg);
|
|
transition: none;
|
|
}
|
|
|
|
.toast.entering.show {
|
|
opacity: 1;
|
|
transform: translateX(0) translateZ(0) rotateY(0);
|
|
transition:
|
|
transform 0.6s cubic-bezier(0.23, 1, 0.32, 1),
|
|
opacity 0.5s cubic-bezier(0.23, 1, 0.32, 1),
|
|
filter 0.4s ease;
|
|
}
|
|
|
|
/* ========== 堆叠层级系统 ========== */
|
|
.toast:nth-child(1) {
|
|
z-index: 5;
|
|
transform: translateZ(0) translateY(0) scale(1);
|
|
opacity: 1;
|
|
filter: brightness(1);
|
|
}
|
|
|
|
.toast:nth-child(2) {
|
|
z-index: 4;
|
|
transform: translateZ(-50px) translateY(24px) scale(0.94);
|
|
opacity: 0.9;
|
|
filter: brightness(0.97);
|
|
}
|
|
|
|
.toast:nth-child(3) {
|
|
z-index: 3;
|
|
transform: translateZ(-100px) translateY(48px) scale(0.88);
|
|
opacity: 0.75;
|
|
filter: brightness(0.94);
|
|
}
|
|
|
|
.toast:nth-child(4) {
|
|
z-index: 2;
|
|
transform: translateZ(-150px) translateY(72px) scale(0.82);
|
|
opacity: 0.6;
|
|
filter: brightness(0.91);
|
|
}
|
|
|
|
.toast:nth-child(5) {
|
|
z-index: 1;
|
|
transform: translateZ(-200px) translateY(96px) scale(0.76);
|
|
opacity: 0.45;
|
|
filter: brightness(0.88);
|
|
}
|
|
|
|
.toast:nth-child(n+6) {
|
|
display: none;
|
|
}
|
|
|
|
/* ========== 层级过渡 ========== */
|
|
.toast.shift-down {
|
|
transition:
|
|
transform 0.5s cubic-bezier(0.23, 1, 0.32, 1),
|
|
opacity 0.4s ease,
|
|
filter 0.4s ease;
|
|
}
|
|
|
|
/* ========== 悬停展开 ========== */
|
|
#toast-stage:hover .toast {
|
|
transition:
|
|
transform 0.5s cubic-bezier(0.23, 1, 0.32, 1),
|
|
opacity 0.4s ease,
|
|
filter 0.4s ease;
|
|
}
|
|
|
|
#toast-stage:hover .toast:nth-child(1) {
|
|
transform: translateZ(0) translateY(0) scale(1) !important;
|
|
opacity: 1 !important;
|
|
filter: brightness(1) !important;
|
|
}
|
|
|
|
#toast-stage:hover .toast:nth-child(2) {
|
|
transform: translateZ(0) translateY(80px) scale(1) !important;
|
|
opacity: 1 !important;
|
|
filter: brightness(1) !important;
|
|
}
|
|
|
|
#toast-stage:hover .toast:nth-child(3) {
|
|
transform: translateZ(0) translateY(160px) scale(1) !important;
|
|
opacity: 1 !important;
|
|
filter: brightness(1) !important;
|
|
}
|
|
|
|
#toast-stage:hover .toast:nth-child(4) {
|
|
transform: translateZ(0) translateY(240px) scale(1) !important;
|
|
opacity: 1 !important;
|
|
filter: brightness(1) !important;
|
|
}
|
|
|
|
#toast-stage:hover .toast:nth-child(5) {
|
|
transform: translateZ(0) translateY(320px) scale(1) !important;
|
|
opacity: 1 !important;
|
|
filter: brightness(1) !important;
|
|
}
|
|
|
|
/* ========== 退出动画 ========== */
|
|
.toast.exiting {
|
|
opacity: 0 !important;
|
|
transform: translateX(100px) translateZ(-100px) scale(0.8) rotateY(-15deg) !important;
|
|
transition:
|
|
transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
|
|
opacity 0.3s ease !important;
|
|
pointer-events: none;
|
|
}
|
|
|
|
#toast-stage:hover .toast.exiting {
|
|
opacity: 0 !important;
|
|
transform: translateX(80px) scale(0.9) !important;
|
|
transition:
|
|
transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
|
|
opacity 0.25s ease !important;
|
|
}
|
|
|
|
#toast-stage:hover .toast.exiting:nth-child(1) {
|
|
transform: translateX(80px) translateY(0) scale(0.9) !important;
|
|
}
|
|
|
|
#toast-stage:hover .toast.exiting:nth-child(2) {
|
|
transform: translateX(80px) translateY(80px) scale(0.9) !important;
|
|
}
|
|
|
|
#toast-stage:hover .toast.exiting:nth-child(3) {
|
|
transform: translateX(80px) translateY(160px) scale(0.9) !important;
|
|
}
|
|
|
|
#toast-stage:hover .toast.exiting:nth-child(4) {
|
|
transform: translateX(80px) translateY(240px) scale(0.9) !important;
|
|
}
|
|
|
|
#toast-stage:hover .toast.exiting:nth-child(5) {
|
|
transform: translateX(80px) translateY(320px) scale(0.9) !important;
|
|
}
|
|
|
|
/* ========== 补位动画 ========== */
|
|
.toast.reordering {
|
|
transition:
|
|
transform 0.5s cubic-bezier(0.23, 1, 0.32, 1),
|
|
opacity 0.4s ease,
|
|
filter 0.4s ease;
|
|
}
|
|
|
|
/* ========== 类型样式 ========== */
|
|
.toast.success {
|
|
background: rgba(240, 253, 244, 0.85);
|
|
color: #166534;
|
|
border-color: rgba(22, 163, 74, 0.2);
|
|
}
|
|
|
|
.toast.error {
|
|
background: rgba(254, 242, 242, 0.85);
|
|
color: #991b1b;
|
|
border-color: rgba(220, 38, 38, 0.2);
|
|
}
|
|
|
|
.toast.info {
|
|
background: rgba(239, 246, 255, 0.85);
|
|
color: #1e40af;
|
|
border-color: rgba(37, 99, 235, 0.2);
|
|
}
|
|
|
|
.toast.warning {
|
|
background: rgba(255, 251, 235, 0.85);
|
|
color: #92400e;
|
|
border-color: rgba(217, 119, 6, 0.2);
|
|
}
|
|
|
|
/* ========== 深色模式 ========== */
|
|
.dark .toast.success {
|
|
background: rgba(22, 163, 74, 0.15);
|
|
color: #86efac;
|
|
border-color: rgba(22, 163, 74, 0.25);
|
|
}
|
|
|
|
.dark .toast.error {
|
|
background: rgba(220, 38, 38, 0.15);
|
|
color: #fca5a5;
|
|
border-color: rgba(220, 38, 38, 0.25);
|
|
}
|
|
|
|
.dark .toast.info {
|
|
background: rgba(37, 99, 235, 0.15);
|
|
color: #93c5fd;
|
|
border-color: rgba(37, 99, 235, 0.25);
|
|
}
|
|
|
|
.dark .toast.warning {
|
|
background: rgba(217, 119, 6, 0.15);
|
|
color: #fcd34d;
|
|
border-color: rgba(217, 119, 6, 0.25);
|
|
}
|
|
|
|
/* ========== 手机端适配 ========== */
|
|
@media (max-width: 640px) {
|
|
#toast-stage {
|
|
top: auto;
|
|
bottom: 80px;
|
|
left: 50%;
|
|
right: auto;
|
|
transform: translateX(-50%);
|
|
width: calc(100% - 32px);
|
|
max-width: 400px;
|
|
padding-bottom: env(safe-area-inset-bottom, 0px);
|
|
}
|
|
|
|
#toast-container {
|
|
height: auto;
|
|
min-height: 80px;
|
|
perspective: none;
|
|
transform-style: flat;
|
|
display: flex;
|
|
flex-direction: column-reverse;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.toast {
|
|
position: relative;
|
|
width: 100%;
|
|
max-width: 100%;
|
|
padding: 16px 20px;
|
|
border-radius: 16px;
|
|
font-size: 15px;
|
|
box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
min-height: 56px;
|
|
/* 默认最终状态 */
|
|
transform: translateY(0) scale(1);
|
|
opacity: 1;
|
|
}
|
|
|
|
/* 入场:从下方滑入(与出场方向相反,对称) */
|
|
.toast.entering {
|
|
transform: translateY(20px) scale(0.95);
|
|
opacity: 0;
|
|
transition: none;
|
|
}
|
|
|
|
.toast.entering.show {
|
|
transform: translateY(0) scale(1);
|
|
opacity: 1;
|
|
/* 与出场动画时间一致 */
|
|
transition:
|
|
transform 0.3s ease,
|
|
opacity 0.25s ease;
|
|
}
|
|
|
|
/* 只显示最新 */
|
|
.toast:nth-child(n+2) {
|
|
display: none;
|
|
}
|
|
|
|
.toast:nth-child(1) {
|
|
transform: translateY(0) scale(1);
|
|
opacity: 1;
|
|
z-index: 10;
|
|
}
|
|
|
|
/* 出场:向下滑出 + 缩小(与入场对称) */
|
|
.toast.exiting {
|
|
transform: translateY(20px) scale(0.95) !important;
|
|
opacity: 0 !important;
|
|
transition:
|
|
transform 0.3s ease,
|
|
opacity 0.25s ease !important;
|
|
}
|
|
|
|
.toast.swiping {
|
|
transition: none !important;
|
|
opacity: 0.8;
|
|
}
|
|
|
|
.dark .toast {
|
|
box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
}
|
|
}
|
|
|
|
@media (max-width: 380px) {
|
|
#toast-stage {
|
|
width: calc(100% - 24px);
|
|
bottom: 70px;
|
|
}
|
|
|
|
.toast {
|
|
padding: 14px 16px;
|
|
font-size: 14px;
|
|
min-height: 52px;
|
|
}
|
|
}
|