Repository navigation
fix(theme): 修复 Linkcard 图标滚动时遮挡顶栏的问题并规范 medium-zoom 目标 - #156
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更说明
问题背景
在页面滚动时(例如
manual/deployment/windows中的一键包 Linkcard 跳转卡片),其右侧的 logo 图标滚动到页面顶栏(.VPNav)区域时会直接漂浮叠在顶栏之上(如原图所示遮挡了「常见问题」「更新日志」「关于」等菜单项)。原因排查
.medium-zoom-image作用时机有误:medium-zoom初始化时会为匹配到的所有img预先挂载.medium-zoom-image类;.vitepress/theme/style.css中直接设置了.medium-zoom-image { z-index: 9999 !important; },导致所有常态下的静态图片也被赋予了极高的 z-index;.linkcard-logo为display: flex,根据 CSS Flexbox 规范,flex 子项的z-index即使在position: static下也会生效并创建层叠上下文;.VPNav的 z-index 仅为 30(9999 > 30),导致卡片图标直接穿透并叠在顶栏上方。medium-zoom误选了链接卡片图标:.vitepress/theme/index.ts中初始化选择器为.main img,导致本应用作外链跳转的<Linkcard>小图标也被纳入图片画廊缩放监听。修复方案
style.css):.medium-zoom-image改为.medium-zoom-image--opened;z-index: 9999 !important(以压住z-index: 100的遮罩层),常态图片恢复默认层叠顺序。index.ts):.main img:not(.linkcard img),避免对链接卡片图标挂载图片放大功能。Linkcard.vue):.linkcard容器添加isolation: isolate;,防止卡片内未来任何子项意外逸出污染页面根层叠上下文。验证情况
manual/deployment/windows,卡片图标正常滚动并遮隐于顶栏下方;openedZIndex: 9999);pnpm docs:build构建通过;node scripts/docs-quality.mjs门禁 8 项检查全部 0 违规通过。