11: root {
22 /* 调整侧边栏宽度 */
3- --vp-sidebar-width : 280 px ;
3+ --vp-sidebar-width : 300 px ;
44
55 /* 让布局占满全屏,消除左侧留白 */
66 --vp-layout-max-width : 100% ;
2121}
2222
2323.VPSidebarItem .link {
24- padding-top : 6 px !important ;
25- padding-bottom : 6 px !important ;
24+ padding-top : 2 px !important ;
25+ padding-bottom : 2 px !important ;
2626}
2727
2828.VPSidebarItem .link : hover .text {
29- color : var (--vp-c-brand -1 );
29+ color : var (--vp-c-text -1 ) !important ;
3030}
3131
3232/* 侧边栏交互效果优化 */
3333.VPSidebarItem > .item {
3434 transition : background-color 0.25s ;
3535 border-radius : 8px ;
36- margin-right : 8px ;
37- /* 侧边栏右侧留白 */
38- padding : 2px 0 ;
39- /* 微调内边距 */
36+ /* 去除负边距,由于外壳去除了右留白,现在直接用 padding 控制即可 */
37+ margin-right : 0 !important ;
38+ margin-left : -16px ;
39+ /* 侧边栏整体留白变小,向边缘靠拢 */
40+ padding : 4px 24px 4px 16px !important ;
4041}
4142
4243/* 悬停效果:整个块背景变色,文字不动 */
4344.VPSidebarItem > .item : hover {
44- background-color : var ( --vp-c-bg-soft ) ;
45+ background-color : rgba ( 193 , 195 , 198 , 0.15 ) !important ;
4546}
4647
47- /* 选中效果:整个块高亮,文字颜色不变 */
48+ /* 选中效果:整个块变色(浅蓝色) */
4849.VPSidebarItem .is-active > .item {
49- background-color : var ( --vp-c-bg-soft ) ;
50+ background-color : rgba ( 193 , 195 , 198 , 0.15 ) !important ;
5051}
5152
52- /* 强制选中时文字颜色与普通文字一致 */
53- .VPSidebarItem .is-active > .item > . link > .text {
53+ /* 强制选中时文字颜色保持普通文本颜色,不额外变色 */
54+ .VPSidebarItem .is-active .item .text {
5455 color : var (--vp-c-text-1 ) !important ;
5556}
5657
7071.VPSidebarItem .level-0 .text {
7172 font-weight : 700 ;
7273 color : var (--vp-c-text-1 );
74+ }
75+
76+ /* 子菜单选项额外缩进(层级递进) */
77+ .VPSidebarItem .level-1 .item .link {
78+ padding-left : 16px !important ;
79+ }
80+
81+ .VPSidebarItem .level-2 .item .link {
82+ padding-left : 32px !important ;
83+ }
84+
85+ .VPSidebarItem .level-3 .item .link {
86+ padding-left : 48px !important ;
87+ }
88+
89+ .VPSidebarItem .level-4 .item .link {
90+ padding-left : 64px !important ;
91+ }
92+
93+ /* 去除侧边栏与主体之间的垂直分割线,解锁右侧留白限制 */
94+ .VPSidebar {
95+ border-right : none !important ;
96+ /* 关键修复:去除 Vitepress 容器默认死板的 32px 右侧留白 (死角区) */
97+ padding-right : 0 !important ;
98+ }
99+
100+ /* 确保内部各级菜单容器占满剩下的空间 */
101+ .VPSidebar .nav ,
102+ .VPSidebar .group ,
103+ .VPSidebarItem {
104+ width : 100% !important ;
105+ }
106+
107+ /* 去除菜单左侧自带的层级提示竖线/边框 */
108+ .VPSidebarItem .item {
109+ border-left : none !important ;
110+ }
111+
112+ /* 隐藏 VitePress 自带的选中项指示竖条 */
113+ .VPSidebarItem .indicator {
114+ display : none !important ;
115+ }
116+
117+ /* 去除侧边栏一级菜单组(Group)之间的水平分割线 */
118+ .VPSidebarGroup ,
119+ .VPSidebarGroup + .VPSidebarGroup ,
120+ section .VPSidebarItem .level-0 ,
121+ .VPSidebar .divider ,
122+ .VPSidebarItem .level-0 {
123+ border-top : none !important ;
124+ border-bottom : none !important ;
125+ padding-top : 0 !important ;
126+ /* Vitepress 有时不仅用 border,还用 padding 隔开各 section */
127+ }
128+
129+ /* 强力清除 VitePress 默认加在 section 或 div 上的所有 border */
130+ .VPSidebarGroup > section ,
131+ .VPSidebarGroup > .group ,
132+ .group + .group ,
133+ .VPSidebarGroup + .VPSidebarGroup {
134+ border-top : 0 !important ;
135+ border-bottom : 0 !important ;
136+ }
137+
138+ /* 隐藏可能存在的默认水平线元素 */
139+ .VPSidebar .divider ,
140+ .VPSidebarGroup hr ,
141+ .VPSidebar hr {
142+ display : none !important ;
143+ border : none !important ;
144+ opacity : 0 !important ;
145+ }
146+
147+ /* =========================================
148+ 缩小菜单和上下级子菜单之间的垂直留白
149+ ========================================= */
150+
151+ /* 1. 大幅减小一级标题与其下方子菜单之间的间距(VitePress 默认高达 24px) */
152+ .VPSidebarItem .level-0 {
153+ padding-bottom : 4px !important ;
154+ }
155+
156+ .VPSidebarItem .collapsed .level-0 {
157+ padding-bottom : 4px !important ;
158+ }
159+
160+ /* 2. 减小所有层级标题本身在垂直方向占据的高度 */
161+ .VPSidebarItem .text {
162+ line-height : 20px !important ;
163+ }
164+
165+ .VPSidebarItem .link {
166+ line-height : 20px !important ;
167+ }
168+
169+ /* 3. 紧缩上方分组与下方分组之间的边距 */
170+ .VPSidebarGroup {
171+ padding-top : 12px !important ;
172+ padding-bottom : 0 !important ;
73173}
0 commit comments