diff --git a/index.html b/index.html index 7210678..43ef2af 100644 --- a/index.html +++ b/index.html @@ -18,8 +18,7 @@ } * { box-sizing: border-box; } html { - overflow-y: scroll; - overflow-x: auto; + overflow-x: hidden; margin: 0; padding: 0; } @@ -30,7 +29,8 @@ "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); - overflow-x: auto; + overflow-x: hidden; + width: 100vw; scroll-behavior: smooth; } #pageContent { @@ -56,6 +56,7 @@ position: fixed; top: 0; left: 0; + right: 0; z-index: 1000; background: transparent; border-bottom: none; @@ -72,8 +73,8 @@ justify-content: space-between; height: 64px; padding: 0 32px; - width: 1280px; - max-width: 1280px; + max-width: 1400px; + width: 100%; margin: 0 auto; position: relative; } @@ -3558,6 +3559,13 @@ content.style.transformOrigin = 'top left'; content.style.width = `${designWidth}px`; + // 用负 margin 收回 scale 后多出的底部布局空间 + // transform:scale 不改变 DOM 布局尺寸,视觉缩小但布局仍占原大小 + // marginBottom = -(原高度 - 缩放后高度) 让滚动范围刚好匹配视觉内容 + const layoutH = content.scrollHeight; + const visualH = layoutH * s; + content.style.marginBottom = `-${Math.ceil(layoutH - visualH)}px`; + // navbar 单独缩放(fixed 不受 content transform 影响) if (navbar) { navbar.style.transform = `scale(${s})`; @@ -3571,8 +3579,17 @@ } } + function fixLayout() { + const s = content.getBoundingClientRect().width / content.scrollWidth; + const layoutH = content.scrollHeight; + const visualH = layoutH * s; + content.style.marginBottom = `-${Math.ceil(layoutH - visualH)}px`; + } + scale(); window.addEventListener('resize', scale); + window.addEventListener('load', fixLayout); + setTimeout(fixLayout, 2000); })(); +