Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sticky-header.component.scss 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. .sticky-header {
  2. position: sticky;
  3. top: 0;
  4. z-index: 1000; /* 进一步提高z-index确保在最顶部 */
  5. transition: all 0.3s ease-in-out;
  6. margin-bottom: 1.5rem; /* 为内容区域提供间距 */
  7. align-self: flex-start; /* 确保在flex容器中sticky生效 */
  8. background-color: white; /* 确保不透明,防止内容透出 */
  9. /* 创建新的层叠上下文,确保z-index生效 */
  10. transform: translateZ(0);
  11. will-change: transform;
  12. /* 轻微的内阴影,增强立体感 */
  13. box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.8);
  14. .header-content {
  15. background: #f8fafc; /* 简洁的灰白色背景 */
  16. border-radius: 0.5rem;
  17. border: 1px solid #e2e8f0; /* 柔和的边框 */
  18. box-shadow:
  19. inset 0 2px 4px 0 rgba(0, 0, 0, 0.06), /* 轻微内阴影,创造凹陷感 */
  20. inset 0 0 0 1px rgba(255, 255, 255, 0.9), /* 内边缘高光,增强立体感 */
  21. 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* 轻微外阴影,保持与页面融合 */
  22. transition: all 0.3s ease-in-out;
  23. /* 移除 overflow: hidden,防止内容裁剪 */
  24. }
  25. .header-title {
  26. font-size: 1.75rem; /* text-3xl */
  27. font-weight: 800;
  28. transition: all 0.3s ease-in-out;
  29. margin: 0;
  30. color: #1e293b; /* text-slate-800 */
  31. text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8); /* 轻微文字阴影,增强可读性 */
  32. }
  33. .debug-section {
  34. transition: all 0.3s ease-in-out;
  35. max-height: 200px;
  36. opacity: 1;
  37. .debug-info, .debug-urls {
  38. &:not(:last-child) {
  39. border-bottom: 1px solid #e2e8f0; /* border-slate-200 */
  40. }
  41. }
  42. }
  43. .hint-section {
  44. transition: all 0.3s ease-in-out;
  45. max-height: 100px;
  46. opacity: 1;
  47. }
  48. /* 锁定状态 - 固定在视口顶部,保持原大小 */
  49. &.locked {
  50. position: fixed;
  51. top: 0;
  52. z-index: 1100; /* 提高z-index确保在最顶层 */
  53. margin-bottom: 0; /* 移除margin,因为现在是fixed定位 */
  54. transform: none; /* 移除transform层叠上下文 */
  55. will-change: auto;
  56. box-shadow: none; /* 移除外阴影,增强一体感 */
  57. background-color: white; /* 确保背景不透明 */
  58. .header-content {
  59. border-radius: 0.5rem;
  60. box-shadow:
  61. inset 0 2px 4px 0 rgba(0, 0, 0, 0.06),
  62. inset 0 0 0 1px rgba(255, 255, 255, 0.9); /* 内阴影,增强一体感 */
  63. background: #f1f5f9;
  64. border: 1px solid #cbd5e1;
  65. margin: 0; /* 移除外边距,确保精确对齐 */
  66. /* 保持原padding大小 */
  67. }
  68. .header-title {
  69. /* 保持原字体大小:1.75rem */
  70. font-weight: 800;
  71. color: #1e293b;
  72. text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  73. }
  74. .hint-section {
  75. max-height: 0;
  76. opacity: 0;
  77. padding-top: 0;
  78. padding-bottom: 0;
  79. border: none;
  80. p {
  81. font-size: 0.8125rem;
  82. opacity: 0;
  83. }
  84. }
  85. .debug-section {
  86. max-height: 0;
  87. opacity: 0;
  88. .debug-info, .debug-urls {
  89. padding-top: 0;
  90. padding-bottom: 0;
  91. font-size: 0.6875rem;
  92. opacity: 0;
  93. border: none;
  94. }
  95. }
  96. }
  97. /* 缩小状态 - 在锁定基础上进一步缩小 */
  98. &.compact {
  99. .header-content {
  100. border-radius: 0.375rem;
  101. box-shadow:
  102. inset 0 3px 6px 0 rgba(0, 0, 0, 0.08), /* 更强的内阴影,增强凹陷感 */
  103. inset 0 0 0 1px rgba(255, 255, 255, 0.8); /* 内边缘高光,增强一体感 */
  104. background: #f1f5f9; /* 稍微深一点的背景,强调状态变化 */
  105. border: 1px solid #cbd5e1; /* 保持一致的边框 */
  106. > div:first-child {
  107. padding-top: 0.375rem;
  108. padding-bottom: 0.375rem;
  109. }
  110. }
  111. .header-title {
  112. font-size: 1.125rem; /* 更小一点 */
  113. font-weight: 800;
  114. color: #0f172a; /* 更深的文字颜色,增强可读性 */
  115. text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9); /* 保持文字阴影 */
  116. letter-spacing: -0.025em; /* 紧凑的字母间距 */
  117. }
  118. .hint-section {
  119. max-height: 0;
  120. opacity: 0;
  121. padding-top: 0;
  122. padding-bottom: 0;
  123. border: none;
  124. p {
  125. font-size: 0.8125rem; /* 比text-sm小一点 */
  126. opacity: 0;
  127. }
  128. }
  129. .debug-section {
  130. max-height: 0;
  131. opacity: 0;
  132. .debug-info, .debug-urls {
  133. padding-top: 0;
  134. padding-bottom: 0;
  135. font-size: 0.6875rem; /* 比text-xs更小 */
  136. opacity: 0;
  137. border: none;
  138. }
  139. }
  140. }
  141. }