feat(footer): 功能页页脚固定底部 + 修掉功能页多余滚动条

问题:上一版页脚改为流内元素后,功能页出现莫名滚动条。实测根因=页脚在流内占位
(margin-top40+高41=81px),把'内容刚好一屏'的功能页(848/900)顶出27px。实测/hash-text
溢出27px、隐藏页脚后=0,页脚是唯一成因。

改法:BaseLayout 加 fixedFooter 开关,功能页(tool.layout.vue -> <BaseLayout fixed-footer>)
页脚 position:fixed 固定视口底部;首页等仍流内最底部。
- fixed 态不占文档流 -> /hash-text 等多余滚动条消失(27->0)
- 功能页内容底部补 padding-bottom:56px,避免滚到底时压住最后一块内容(余量25px起)

对齐修正:固定页脚默认以视口居中(720),首页静态页脚居中于内容区(840,侧栏240px),
切换页面横向跳动120px -> .content 加 transform:translateZ(0) 建立包含块,两边偏差均为0

验证(20个功能页):fixed/padB56/距底12/居中偏差0/单行/滚到底无遮挡(余25-477px)全通过;
受控页试用浮条在顶部与页脚无冲突;非功能页(/,/about,/pricing)仍 static
This commit is contained in:
personal82555 committed 2026-10-15 11:01:07 +08:00
1 parent 9e0c38f23b
commit 7aeb8b74ef
4 files changed
+45 -5

No files matched your search

+12
View File
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. See [standa
## Version 2026.10.14-it-tools-pro
### 🦶 功能页页脚固定在底部 + 修掉功能页的多余滚动条
- **问题**:上一版页脚改为流内元素后,功能页出现**莫名其妙的滚动条** —— 实测根因是页脚在内容流内占位(`margin-top 40 + 高 41 = 81px`),把"内容刚好一屏"的功能页(内容高 848 / 可视 900)顶出 27px 溢出。实测 `/hash-text`:溢出 27px,**隐藏页脚后 = 0**,页脚是唯一成因
- **改法**:给 `BaseLayout` 加 `fixedFooter` 开关,功能页(`tool.layout.vue` → `<BaseLayout fixed-footer>`)页脚 `position: fixed` 固定视口底部;首页等仍为流内最底部
- `fixed` 态不再占文档流 → **`/hash-text` 等页面的多余滚动条消失**(溢出 27 → 0)
- 功能页内容底部补 `padding-bottom: 56px`,避免滚到底时页脚压住最后一块内容(实测余量 25px 起)
- **对齐修正**:固定页脚默认以**视口**为参照居中(720),而首页静态页脚居中于**内容区**(840,侧栏 240px),切换页面会横向跳动 120px → 给 `.content` 加 `transform: translateZ(0)` 建立包含块,使固定页脚也以内容区为参照;实测两边居中偏差均为 **0**
- **验证(20 个功能页全覆盖)**:`position: fixed` ✓、`padding-bottom: 56px` ✓、距视口底 12px ✓、居中偏差 0 ✓、单行 ✓、**滚到底无遮挡**(余量 25–477px)✓
- 无多余滚动条:`/hash-text`、`/uuid-generator`、`/token-generator`、`/lorem-ipsum-generator`、`/color-converter`、`/date-converter`、`/chmod-calculator`、`/ulid-generator`、`/bip39-generator`、`/copywriting` 等
- 内容本身超长的页面(`/emoji-picker` 24131px、`/base64-string-converter`、`/encryption`、`/ipv4-subnet-calculator`、`/label-designer`、`/ai-chat`、`/translator`、`/image-ocr`、`/pdf-ocr`、`/text-to-image`)保留滚动条(本就该有),且底部内容不被遮挡
- 受控页试用浮条在顶部(top 70),与底部页脚**无冲突** ✓
- 非功能页(`/`、`/about`、`/pricing`)仍为 `static` 流内最底部 ✓
### 🦶 页脚改为内容流最底部(取消固定)
- **上一版**:`position: fixed` + `left:0; right:0; bottom:12` 贴住视口底部,**浮在内容之上**
- **现在**:改为**常规流内元素**(`position: static`),排在页面内容**最末尾**,随内容滚动
+4
View File
@@ -43,6 +43,10 @@ const siderPosition = computed(() => (isSmallScreen.value ? 'absolute' : 'static
.content {
// background-color: #f1f5f9;
// 建立包含块:让内容区内 position:fixed 的页脚以「内容区」为参照居中,
// 与首页(静态页脚,居中于内容区)保持一致,避免切换页面时页脚横向跳动
transform: translateZ(0);
::v-deep(.n-layout-scroll-container) {
padding: 26px;
}
+28 -4
View File
@@ -20,6 +20,9 @@ import UserMenu from '@/components/UserMenu.vue';
const themeVars = useThemeVars();
const styleStore = useStyleStore();
// 页脚模式:默认随内容排在页面最底部(首页等);功能页传入 fixedFooter 改为固定在视口底部
const props = withDefaults(defineProps<{ fixedFooter?: boolean }>(), { fixedFooter: false });
// 已登录用户每次打开页面:自动拉取一次云端数据(收藏/记录/对话等跨设备恢复)
const { syncNow, isLoggedIn } = useCloudSync();
if (isLoggedIn.value) {
@@ -81,7 +84,7 @@ onBeforeUnmount(() => {
</script>
<template>
<MenuLayout class="menu-layout" :class="{ isSmallScreen: styleStore.isSmallScreen }">
<MenuLayout class="menu-layout" :class="{ isSmallScreen: styleStore.isSmallScreen, 'fixed-footer': props.fixedFooter }">
<template #sider>
<RouterLink to="/" class="hero-wrapper">
<HeroGradient class="gradient" />
@@ -157,8 +160,8 @@ onBeforeUnmount(() => {
</div>
<slot />
<!-- 底部居中固定页脚(单行横排) -->
<div class="footer">
<!-- 页脚:功能页固定在底部,其它页随内容排在页面最底部 -->
<div class="footer" :class="{ fixed: props.fixedFooter }">
<span>© {{ new Date().getFullYear() }} IT-TOOLS-PRO</span>
<span class="footer-sep">·</span>
<span>
@@ -228,7 +231,7 @@ onBeforeUnmount(() => {
}
}
/* 页脚:置于页面内容最底部(不固定、随内容滚动),单行横排居中 */
/* 页脚:默认随内容排在页面最底部(不固定、随内容滚动),单行横排居中 */
.footer {
margin-top: 40px;
padding: 0 0 22px;
@@ -252,6 +255,27 @@ onBeforeUnmount(() => {
color: #0e9384;
}
}
// 功能页:固定在视口底部居中;不再占据文档流,因此不会把"刚好一屏"的页面顶出滚动条
&.fixed {
position: fixed;
left: 0;
right: 0;
bottom: 12px;
z-index: 350;
margin: 0;
padding: 0;
pointer-events: none; // 不拦截下方内容点击,仅链接可点
:deep(a) {
pointer-events: auto;
}
}
}
/* 功能页:内容底部留出页脚高度,避免滚到底时页脚压住最后一块内容 */
.menu-layout.fixed-footer :deep(.content .n-layout-scroll-container) {
padding-bottom: 56px;
}
// 顶部导航:滚动时固定在最顶部(sticky),通栏贴顶遮挡滚动内容
+1 -1
View File
@@ -98,7 +98,7 @@ function retryAiHelp() {
</script>
<template>
<BaseLayout>
<BaseLayout fixed-footer>
<div class="tool-layout" :class="{ wide: isWide }">
<div class="tool-header">
<div flex flex-nowrap items-center gap-12px>