Brak opisu
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.7KB

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