/* * 轻量级顶部通知样式 * 在页面顶部显示简洁的通知横条 */ /* 通知容器 */ .toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 99999; display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 800px; /* 增加最大宽度,但保持在移动设备上的响应式 */ padding: 0 20px; box-sizing: border-box; pointer-events: none; } /* 通知条样式 */ .toast { background-color: #fff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); padding: 12px 16px; display: flex; align-items: flex-start; justify-content: space-between; width: max-content; min-width: 300px; max-width: 450px; animation: slideInDown 0.3s ease forwards; overflow: visible; pointer-events: auto; border-left: 4px solid #1890ff; margin: 0 auto; box-sizing: border-box; } /* 多行文本的Toast样式调整 */ .toast.toast-multiline { padding-top: 14px; padding-bottom: 14px; } .toast.closing { animation: slideOutUp 0.3s ease forwards; } .toast-content { display: flex; align-items: flex-start; flex: 1; min-width: 0; margin-right: 8px; } /* 图标容器 */ .toast-icon-wrapper { margin-right: 12px; flex-shrink: 0; margin-top: 2px; width: 24px; } /* 通知图标 */ .toast-icon { font-size: 20px; height: 20px; width: 20px; display: flex; align-items: center; justify-content: center; } /* 图标类型样式 */ .toast-icon.success { color: #52c41a; } .toast-icon.error { color: #f5222d; } .toast-icon.warning { color: #faad14; } .toast-icon.info { color: #1890ff; } /* 通知类型样式 */ .toast-success { border-left-color: #52c41a; } .toast-error { border-left-color: #f5222d; } .toast-warning { border-left-color: #faad14; } .toast-info { border-left-color: #1890ff; } /* 消息样式 */ .toast-message { font-size: 14px; line-height: 1.6; color: #333; flex: 1; min-width: 0; text-align: left; padding: 1px 0; /* 简化文本样式 */ white-space: normal; } /* 消息行样式 */ .toast-message-line { display: block; margin-bottom: 3px; } .toast-message-line:last-child { margin-bottom: 0; } /* 对于中文文本特别处理 */ :lang(zh) .toast-message, :lang(zh-CN) .toast-message, :lang(zh-TW) .toast-message { /* 中文特殊处理 */ text-indent: 0; /* 确保没有首行缩进 */ text-align-last: left; /* 确保最后一行也左对齐 */ } /* 对于英文文本,特别处理 */ .toast-message:lang(en) { word-break: normal; } /* 关闭按钮 */ .toast-close { width: 20px; height: 20px; border-radius: 50%; border: none; background-color: transparent; color: #999; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; margin-left: 8px; flex-shrink: 0; padding: 0; align-self: flex-start; margin-top: 2px; } .toast-close:hover { background-color: rgba(0, 0, 0, 0.05); color: #333; } .toast-close i { font-size: 16px; } /* Toast焦点状态样式 */ .toast:focus { outline: none; box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.2); } .toast-success:focus { box-shadow: 0 0 0 3px rgba(82, 196, 26, 0.2); } .toast-error:focus { box-shadow: 0 0 0 3px rgba(245, 34, 45, 0.2); } .toast-warning:focus { box-shadow: 0 0 0 3px rgba(250, 173, 20, 0.2); } /* 动画关键帧 */ @keyframes slideInDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } } @keyframes slideOutUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-20px); opacity: 0; } } /* 响应式样式 */ @media (max-width: 768px) { .toast-container { padding: 0 15px; max-width: 90%; } .toast { min-width: 250px; max-width: 400px; width: auto; } } @media (max-width: 480px) { .toast-container { top: 10px; padding: 0 10px; width: 100%; max-width: 100%; } .toast { padding: 10px 12px; min-width: 0; max-width: 330px; width: calc(100% - 20px); } .toast-icon { font-size: 16px; height: 20px; width: 20px; } .toast-message { font-size: 13px; max-width: calc(100% - 50px); } .toast-close { width: 18px; height: 18px; } .toast-close i { font-size: 14px; } }