Skip to content

Commit 9265e78

Browse files
committed
Move blog toc to left
1 parent 58e92cf commit 9265e78

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

assets/scss/custom.scss

+11
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,14 @@ blockquote {
3232
max-height: 230px; /* 最大高度,内容少时自动收缩 */
3333
overflow-y: auto;
3434
}
35+
36+
/* 目录悬浮动效 */
37+
.sticky-toc {
38+
transition: transform 0.3s ease;
39+
}
40+
/* 移动端隐藏目录 */
41+
@media (max-width: 1024px) {
42+
.absolute.left-0 {
43+
display: none;
44+
}
45+
}

layouts/blog/single.html

+14-3
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,21 @@ <h1 class="h2 mb-4">
4444
{{ time.Format ":date_long" .PublishDate }}
4545
</li> -->
4646
</ul>
47-
<div class="content mb-10">
48-
{{ partial "toc.html" (dict "Class" "blog" "Collapsed" false "TableOfContents" .TableOfContents ) }}
49-
{{ .Content }}
47+
48+
<div class="relative">
49+
<!-- 独立 TOC 容器:固定在左侧 -->
50+
<div class="absolute left-0 top-0 h-full lg:w-3/12 md:w-4/12 pr-4" style="transform: translateX(-100%)">
51+
<div class="sticky top-20 overflow-y-auto max-h-[80vh] pe-4">
52+
{{ partial "toc.html" (dict "Class" "blog" "Collapsed" false "TableOfContents" .TableOfContents ) }}
53+
</div>
54+
</div>
55+
56+
<!-- 主内容区域 -->
57+
<div class="content">
58+
{{ .Content }}
59+
</div>
5060
</div>
61+
5162
<div class="row items-start justify-between">
5263
{{ $tags:= .Params.tags }}
5364
{{ if $tags }}

0 commit comments

Comments
 (0)