Skip to content

Commit 271a157

Browse files
committed
mobile sidenote
1 parent 57aef0e commit 271a157

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

assets/css/extended/sidenote.css

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,58 @@ body {
4949
/* 添加一个平滑的过渡效果 */
5050
transition: all 0.2s ease-in-out;
5151
}
52+
53+
/* ==========================================================================
54+
全新优化的 Sidenote 移动端响应式设计
55+
========================================================================== */
56+
57+
@media (max-width: 1024px) {
58+
59+
/* 1. 重置父容器的桌面端样式 */
60+
.sidenote-container {
61+
all: unset; /* 清除所有桌面端样式,如 float, margin-right 等 */
62+
display: block; /* 让它变为一个块级元素,独占一行 */
63+
margin: 1.5em 0; /* 在注释上下添加一些垂直间距 */
64+
}
65+
66+
/* 2. 让正文中的引用标记 [1] 恢复正常 */
67+
.sidenote-ref {
68+
all: unset; /* 清除桌面端的绝对定位等 */
69+
display: inline; /* 让它像普通文字一样留在正文中 */
70+
71+
/* 恢复它的计数器和基本样式 */
72+
counter-increment: sidenote-counter;
73+
content: "[" counter(sidenote-counter) "]";
74+
vertical-align: super;
75+
font-size: 0.8em;
76+
font-weight: 700;
77+
color: var(--accent);
78+
}
79+
80+
/* 3. 将旁注内容变为一个独立的、漂亮的卡片 (关键优化) */
81+
.sidenote-content {
82+
all: unset; /* 清除所有桌面端样式 */
83+
display: block; /* 变为块级元素,独占一行 */
84+
85+
/* 添加视觉样式,使其像一个注释卡片 */
86+
margin-top: 0.8em; /* 与正文之间留出一些间距 */
87+
padding: 1em 1.2em; /* 内部留白 */
88+
background-color: var(--secondary); /* 使用主题的次要背景色,适配深色模式 */
89+
border-left: 4px solid var(--accent); /* 左侧加一条强调色边框 */
90+
border-radius: 4px; /* 圆角 */
91+
92+
/* 恢复字体样式 */
93+
font-size: 0.9rem;
94+
line-height: 1.7;
95+
color: var(--secondary-text);
96+
}
97+
98+
/* 解决一个边距问题:如果旁注内容里有段落,去掉第一个段落的顶部外边距 */
99+
.sidenote-content > *:first-child {
100+
margin-top: 0;
101+
}
102+
103+
.sidenote-content > *:last-child {
104+
margin-bottom: 0;
105+
}
106+
}

0 commit comments

Comments
 (0)