Add margin notes: Tufte-style side notes with dashed inline fallback

This commit is contained in:
2026-11-15 10:04:32 +08:00
parent 88c8c36d02
commit cfe85f9b16
6 changed files with 188 additions and 8 deletions
+91
View File
@@ -223,3 +223,94 @@ html.dark #post-list .post-card:hover {
#post-list .blog-post-item {
margin-bottom: 1rem;
}
/* ===== 注释(边注):宽屏显示在两侧留白,窄屏虚线框内嵌 ===== */
.post-note-mark {
font-size: 0.7em;
line-height: 0;
vertical-align: super;
margin-left: 0.1em;
color: #2563eb;
font-weight: 600;
}
.dark .post-note-mark {
color: #60a5fa;
}
/* 窄屏 / 无 JS:虚线框内嵌在正文中 */
.post-note {
display: block;
margin: 0.5rem 0;
padding: 0.5rem 0.75rem;
border: 1px dashed #cbd5e1;
border-radius: 0.375rem;
font-size: 0.85rem;
line-height: 1.65;
color: #6b7280;
}
.dark .post-note {
border-color: #404040;
color: #9ca3af;
}
/* 宽屏:由 notes.js 接管,放进正文两侧的留白 */
@media (min-width: 80rem) {
/* 去掉 TOC / 侧栏占位后,把正文栏收回原来的阅读宽度,两侧留给注释 */
main.notes-page {
max-width: 52rem;
margin-left: auto;
margin-right: auto;
}
html.js .post-note {
display: none;
}
html.js main.notes-page.notes-active {
position: relative;
}
html.js main.notes-page.notes-active .post-note.placed {
display: block;
position: absolute;
width: 12rem;
margin: 0;
padding: 0 0.75rem;
border: 0 solid #e5e7eb;
border-radius: 0;
background: none;
font-size: 0.8125rem;
line-height: 1.65;
color: #6b7280;
}
html.dark.js main.notes-page.notes-active .post-note.placed {
color: #9ca3af;
border-color: #333;
}
/* 注释靠在正文哪一侧,就在朝向正文的那边加一条细线 */
html.js main.notes-page.notes-active .post-note.placed[data-side="right"] {
left: calc(100% + 1rem);
right: auto;
border-left-width: 2px;
}
html.js main.notes-page.notes-active .post-note.placed[data-side="left"] {
right: calc(100% + 1rem);
left: auto;
border-right-width: 2px;
}
}
@media print {
.post-note {
display: block !important;
position: static !important;
width: auto !important;
border: 1px dashed #999 !important;
padding: 0.5rem 0.75rem !important;
}
}