Skip to content

Commit 7e1783b

Browse files
author
MLeo
committed
modify
1 parent 069f899 commit 7e1783b

3 files changed

Lines changed: 39 additions & 12 deletions

File tree

‎css/style.css‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
margin: 0;
1111
padding: 0;
1212
box-sizing: border-box;
13+
text-decoration: none;
1314
}
1415

1516
:root {
@@ -265,24 +266,27 @@ body.dark-theme .moon-icon {
265266
.container {
266267
display: grid;
267268
grid-template-columns: minmax(260px, 340px) 1fr;
269+
grid-template-rows: minmax(0, 1fr);
268270
gap: var(--space-3);
269271
align-items: stretch;
270-
flex: 1;
272+
flex: 1 1 auto;
271273
min-height: 0;
272-
height: 100%;
274+
height: auto;
275+
overflow: hidden;
273276
}
274277

275278
.unit-list {
276279
background: var(--glass);
277280
border: 1px solid var(--border);
278281
border-radius: var(--radius-lg);
279282
box-shadow: var(--shadow-sm);
280-
padding: 18px 0;
281283
height: 100%;
282284
display: flex;
283285
flex-direction: column;
284286
min-height: 0;
285-
overflow: hidden;
287+
overflow-y: auto;
288+
overflow-x: hidden;
289+
overscroll-behavior: contain;
286290
animation: riseIn 0.6s ease both;
287291
animation-delay: 0.05s;
288292
}
@@ -293,27 +297,32 @@ body.dark-theme .moon-icon {
293297

294298
.unit-list h2 {
295299
color: var(--ink-2);
296-
margin-bottom: 14px;
300+
margin: 0;
297301
font-size: 20px;
298302
font-weight: 700;
299303
letter-spacing: 0.2em;
300304
text-transform: uppercase;
301305
padding: 10px 20px;
302306
font-family: var(--font-mono);
303-
border-bottom: 1px solid var(--border) ;
307+
border-bottom: 1px solid var(--border);
308+
position: sticky;
309+
top: 0;
310+
z-index: 1;
311+
background: var(--glass);
312+
backdrop-filter: blur(18px) saturate(130%);
313+
-webkit-backdrop-filter: blur(18px) saturate(130%);
314+
flex-shrink: 0;
304315
}
305316

306317
#unitListContainer {
307318
display: flex;
308319
flex-direction: column;
309320
gap: 6px;
310321
width: 100%;
311-
padding: 0 10px 14px;
312-
overflow-y: auto;
313-
overflow-x: hidden;
314-
flex: 1 1 auto;
322+
padding: 10px 14px;
315323
min-height: 0;
316-
height: 100%;
324+
height: auto;
325+
padding-bottom: 18px;
317326
}
318327

319328
.unit-item {
@@ -356,6 +365,7 @@ body.dark-theme .moon-icon {
356365
flex-direction: column;
357366
gap: var(--space-2);
358367
min-height: 0;
368+
height: 100%;
359369
}
360370

361371
.player-column .player-section {
@@ -1160,6 +1170,7 @@ body.blur-translation .lyric-line:hover .lyric-text {
11601170
font-size: 12px;
11611171
color: var(--ink-2);
11621172
font-family: var(--font-mono);
1173+
flex-shrink: 0;
11631174
}
11641175

11651176
html,

‎index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ <h1>新概念英语</h1>
7171
</select>
7272
</label>
7373
<div class="header-actions">
74-
<span class="status-pill">NCE</span>
74+
<span class="status-pill"><a href="https://ichochy.com" target="_blank">Blog</a></span>
7575
<button id="themeToggle" class="theme-toggle" aria-label="切换主题">
7676
<svg class="sun-icon" width="20" height="20" viewBox="0 0 20 20" fill="none">
7777
<circle cx="10" cy="10" r="4" stroke="currentColor" stroke-width="1.5" />

‎js/main.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class ReadingSystem {
151151
await this.loadBookConfig();
152152
this.renderUnitList();
153153
this.renderUnitSelect();
154+
this.resetUnitListScroll();
154155
}
155156

156157
renderEmptyState(message) {
@@ -160,6 +161,14 @@ class ReadingSystem {
160161
if (this.dom.unitList) {
161162
this.dom.unitList.innerHTML = '';
162163
}
164+
this.resetUnitListScroll();
165+
}
166+
167+
resetUnitListScroll() {
168+
const scrollContainer = this.dom.unitList?.closest('.unit-list');
169+
if (scrollContainer) {
170+
scrollContainer.scrollTop = 0;
171+
}
163172
}
164173

165174
async loadBookConfig() {
@@ -306,13 +315,20 @@ class ReadingSystem {
306315

307316
updateActiveUnit(unitIndex) {
308317
if (this.dom.unitList) {
318+
let activeItem = null;
319+
309320
this.dom.unitList.querySelectorAll('.unit-item').forEach((item, index) => {
310321
if (index === unitIndex) {
311322
item.classList.add('active');
323+
activeItem = item;
312324
} else {
313325
item.classList.remove('active');
314326
}
315327
});
328+
329+
if (activeItem) {
330+
activeItem.scrollIntoView({ block: 'center', inline: 'nearest' });
331+
}
316332
}
317333

318334
if (this.dom.unitSelect) {

0 commit comments

Comments
 (0)