styles.scss 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* ============================================================
  2. * 全局 SCSS 助手:动画关键帧 & 通用过渡工具类
  3. * 组件级复杂样式仍写在各自的 .scss 里(便于局部修改)。
  4. * ============================================================ */
  5. // ---- 进入/退出动画关键帧 ----
  6. @keyframes ui-fade-in {
  7. from { opacity: 0; }
  8. to { opacity: 1; }
  9. }
  10. @keyframes ui-fade-out {
  11. from { opacity: 1; }
  12. to { opacity: 0; }
  13. }
  14. @keyframes ui-scale-in {
  15. from { opacity: 0; transform: scale(0.96); }
  16. to { opacity: 1; transform: scale(1); }
  17. }
  18. @keyframes ui-slide-up {
  19. from { opacity: 0; transform: translateY(10px); }
  20. to { opacity: 1; transform: translateY(0); }
  21. }
  22. @keyframes ui-slide-down {
  23. from { opacity: 0; transform: translateY(-10px); }
  24. to { opacity: 1; transform: translateY(0); }
  25. }
  26. @keyframes ui-slide-in-right {
  27. from { transform: translateX(100%); }
  28. to { transform: translateX(0); }
  29. }
  30. @keyframes ui-slide-in-left {
  31. from { transform: translateX(-100%); }
  32. to { transform: translateX(0); }
  33. }
  34. @keyframes ui-shimmer {
  35. from { background-position: 200% 0; }
  36. to { background-position: -200% 0; }
  37. }
  38. @keyframes ui-progress-indeterminate {
  39. 0% { left: -40%; width: 40%; }
  40. 60% { left: 60%; width: 70%; }
  41. 100% { left: 110%; width: 40%; }
  42. }
  43. // ---- 工具类(在模板里可直接用) ----
  44. .animate-fade-in { animation: ui-fade-in 0.18s ease-out both; }
  45. .animate-fade-out { animation: ui-fade-out 0.25s ease-in both; }
  46. .animate-scale-in { animation: ui-scale-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) both; }
  47. .animate-slide-up { animation: ui-slide-up 0.2s ease-out both; }
  48. .animate-slide-down { animation: ui-slide-down 0.2s ease-out both; }
  49. .animate-slide-in-right{ animation: ui-slide-in-right 0.28s cubic-bezier(0.16, 1, 0.3, 1) both; }
  50. .animate-slide-in-left { animation: ui-slide-in-left 0.28s cubic-bezier(0.16, 1, 0.3, 1) both; }
  51. .animate-shimmer { animation: ui-shimmer 1.6s linear infinite; }
  52. // ---- 无障碍:尊重“减少动态效果”偏好 ----
  53. @media (prefers-reduced-motion: reduce) {
  54. *,
  55. *::before,
  56. *::after {
  57. animation-duration: 0.01ms !important;
  58. animation-iteration-count: 1 !important;
  59. transition-duration: 0.01ms !important;
  60. scroll-behavior: auto !important;
  61. }
  62. }