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:
1 parent
9e0c38f23b
commit
7aeb8b74ef
4 files changed
+45
-5
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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),通栏贴顶遮挡滚动内容
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user