feat: 滚动时 banner 动态压缩释放更多内容空间
Deploy Examination / deploy (push) Successful in 30s

- header 改为 flex 布局驱动,滚动超过 60px 自动压缩为紧凑模式
- 压缩态:标题字号缩小、副标题隐藏、添加底部阴影
- body 改为 flex column 布局,去掉硬编码高度计算
- 去除 ResizeObserver 反馈循环,消除滚动抖动

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
2026-09-02 20:27:47 +08:00
parent 3ee95adfb0
commit 7e226ffb6b
+45 -6
View File
@@ -31,17 +31,42 @@
--type-scenario: #a855f7;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; }
body { font-family: -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
/* Header */
.header { background: var(--header-bg); padding: 28px 24px; text-align: center; border-bottom: 1px solid var(--surface2); position: relative; }
.header h1 { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.header p { color: rgba(255,255,255,0.7); font-size: 14px; }
.theme-toggle { position: absolute; top: 16px; right: 16px; background: rgba(255,255,255,0.15); border: none; color: white; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 18px; transition: background 0.2s; }
.header {
background: var(--header-bg); text-align: center; border-bottom: 1px solid var(--surface2);
--header-pad-y: 28px;
padding: var(--header-pad-y) 24px;
transition: padding 0.3s ease, box-shadow 0.3s ease;
flex-shrink: 0;
}
.header.compact {
--header-pad-y: 8px;
box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}
.header h1 {
font-size: 26px; font-weight: 700; margin-bottom: 6px;
transition: font-size 0.3s ease, margin 0.3s ease;
}
.header.compact h1 { font-size: 18px; margin-bottom: 0; }
.header p {
color: rgba(255,255,255,0.7); font-size: 14px;
transition: opacity 0.25s ease, max-height 0.3s ease, margin 0.3s ease;
max-height: 40px; overflow: hidden;
}
.header.compact p { opacity: 0; max-height: 0; margin: 0; }
.theme-toggle {
position: absolute; top: 16px; right: 16px;
background: rgba(255,255,255,0.15); border: none; color: white;
width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
font-size: 18px; transition: background 0.2s, top 0.3s ease;
}
.header.compact .theme-toggle { top: 8px; }
.theme-toggle:hover { background: rgba(255,255,255,0.25); }
/* Layout */
.app { display: flex; height: calc(100vh - 100px); }
.app { display: flex; flex: 1; min-height: 0; }
.sidebar { width: 280px; background: var(--surface); border-right: 1px solid var(--surface2); padding: 16px; overflow-y: auto; flex-shrink: 0; }
.main { flex: 1; padding: 24px; overflow-y: auto; }
@@ -1066,8 +1091,22 @@ function escapeHtml(s) {
return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
// ─── Scroll: compact header on scroll ───
function setupHeaderScroll() {
const main = document.getElementById('mainContent');
const header = document.querySelector('.header');
if (!main || !header) return;
const THRESHOLD = 60;
main.addEventListener('scroll', () => {
header.classList.toggle('compact', main.scrollTop > THRESHOLD);
}, { passive: true });
}
// ─── Start ───
init();
setupHeaderScroll();
</script>
</body>
</html>