Skip to content

Commit 37d5589

Browse files
authored
Merge pull request #28 from 42devops/fix/toc-right-floating-no-squeeze
fix: position TOC in right margin floating panel without squeezing post content
2 parents d269de6 + 1f36216 commit 37d5589

2 files changed

Lines changed: 20 additions & 30 deletions

File tree

‎_layouts/post.html‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,18 @@ <h1 class="post-title">{{ page.title }}</h1>
4141
</div>
4242
</header>
4343

44-
<div class="post-layout">
45-
<aside class="post-sidebar" id="post-sidebar">
46-
<div class="toc-wrapper" id="toc-wrapper" style="display: none;">
47-
<div class="toc-header">
48-
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" x2="3" y1="6" y2="6"/><line x1="15" x2="3" y1="12" y2="12"/><line x1="17" x2="3" y1="18" y2="18"/></svg>
49-
<span>Contents</span>
50-
</div>
51-
<ul class="toc-list" id="toc-list"></ul>
44+
<aside class="post-sidebar" id="post-sidebar">
45+
<div class="toc-wrapper" id="toc-wrapper" style="display: none;">
46+
<div class="toc-header">
47+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="21" x2="3" y1="6" y2="6"/><line x1="15" x2="3" y1="12" y2="12"/><line x1="17" x2="3" y1="18" y2="18"/></svg>
48+
<span>Contents</span>
5249
</div>
53-
</aside>
54-
55-
<div class="post-content" id="post-content">
56-
{{ content }}
50+
<ul class="toc-list" id="toc-list"></ul>
5751
</div>
52+
</aside>
53+
54+
<div class="post-content" id="post-content">
55+
{{ content }}
5856
</div>
5957
</article>
6058

‎css/screen.css‎

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ body {
466466

467467
/* Post Detail Styling */
468468
article.post-detail {
469+
position: relative;
469470
background: var(--bg-card);
470471
border: 1px solid var(--border-color);
471472
border-radius: var(--radius-lg);
@@ -647,30 +648,21 @@ pre code {
647648
color: inherit;
648649
}
649650

650-
/* Post Article Layout & Sticky TOC */
651-
.post-layout {
652-
display: grid;
653-
grid-template-columns: 220px 1fr;
654-
gap: 2.5rem;
655-
align-items: start;
651+
/* Post Article Sticky Floating TOC on Right Margin */
652+
.post-sidebar {
653+
position: absolute;
654+
top: 2.75rem;
655+
left: calc(100% + 1.5rem);
656+
width: 230px;
657+
z-index: 80;
656658
}
657659

658-
@media (max-width: 992px) {
659-
.post-layout {
660-
grid-template-columns: 1fr;
661-
}
660+
@media (max-width: 1280px) {
662661
.post-sidebar {
663-
display: none;
662+
display: none !important;
664663
}
665664
}
666665

667-
.post-sidebar {
668-
position: sticky;
669-
top: 90px;
670-
max-height: calc(100vh - 120px);
671-
overflow-y: auto;
672-
}
673-
674666
.toc-wrapper {
675667
background: var(--bg-card);
676668
border: 1px solid var(--border-color);

0 commit comments

Comments
 (0)