Skip to content

Commit 5cf8b36

Browse files
committed
fix bug
1 parent 5fa8005 commit 5cf8b36

File tree

2 files changed

+76
-13
lines changed

2 files changed

+76
-13
lines changed

assets/css/style.css

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,38 @@ html[lang="zh-CN"] .highlight-card h3 {
780780
padding-bottom: 8px;
781781
}
782782

783+
/* 有链接的成员卡片样式(整个卡片可点击) */
784+
a.member-card-link {
785+
display: flex;
786+
flex-direction: column;
787+
align-items: center;
788+
text-align: center;
789+
min-height: auto;
790+
padding-bottom: 8px;
791+
text-decoration: none;
792+
color: inherit;
793+
transition: transform 0.2s ease;
794+
}
795+
796+
a.member-card-link:hover {
797+
transform: translateY(-4px);
798+
}
799+
800+
a.member-card-link .member-photo {
801+
cursor: pointer;
802+
}
803+
804+
a.member-card-link .member-name {
805+
color: var(--fudan-blue);
806+
cursor: pointer;
807+
transition: color 0.3s ease;
808+
}
809+
810+
a.member-card-link:hover .member-name {
811+
color: var(--text-soft);
812+
text-decoration: underline;
813+
}
814+
783815
.member-photo {
784816
width: 140px;
785817
height: 140px;
@@ -1153,7 +1185,7 @@ html[lang="en"] #resources .resource-card h3 {
11531185

11541186
/* Alumni main container alignment */
11551187
#alumni-main.container, #people-main.container, #resources-main.container, #research-main.container, #highlights-main.container {
1156-
padding-top: 40px !important;
1188+
/* padding-top: 40px !important; */
11571189
}
11581190

11591191
/* Alumni list layout */

assets/js/spa.js

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,34 @@
158158
if (route === 'positions' && params.section) {
159159
setTimeout(() => {
160160
const target = document.getElementById(params.section);
161-
if (target) target.scrollIntoView({ behavior: 'smooth', block: 'start' });
161+
if (target) {
162+
const offset = 120; // 导航栏高度 + 额外间距
163+
const bodyRect = document.body.getBoundingClientRect().top;
164+
const elementRect = target.getBoundingClientRect().top;
165+
const elementPosition = elementRect - bodyRect;
166+
const offsetPosition = elementPosition - offset;
167+
window.scrollTo({ top: offsetPosition, behavior: 'smooth' });
168+
}
162169
}, 50);
163170
}
164171
}
165172

173+
// 滚动到指定区域的函数(用于按钮点击)
174+
function scrollToSection(sectionId) {
175+
const target = document.getElementById(sectionId);
176+
if (target) {
177+
const offset = 120; // 导航栏高度 + 额外间距
178+
const bodyRect = document.body.getBoundingClientRect().top;
179+
const elementRect = target.getBoundingClientRect().top;
180+
const elementPosition = elementRect - bodyRect;
181+
const offsetPosition = elementPosition - offset;
182+
window.scrollTo({ top: offsetPosition, behavior: 'smooth' });
183+
}
184+
}
185+
186+
// 将滚动函数暴露到全局作用域
187+
window.scrollToSection = scrollToSection;
188+
166189
function parseHash() {
167190
const raw = window.location.hash.replace('#', '');
168191
if (!raw) return { route: 'home', params: {} };
@@ -322,17 +345,25 @@
322345
if (!list.length) return `<p>${t('people.updating')}</p>`;
323346
return list.map(member => {
324347
const name = member.name?.[currentLang] || member.name?.zh || member.name;
325-
const nameHtml = member.homepage
326-
? `<a href="${member.homepage}" target="_blank" class="member-name-link">${name}</a>`
327-
: name;
328348

329-
return `
330-
<div class="member-card">
331-
${member.photo ? `<img src="${member.photo}" alt="${name}" class="member-photo">` : ''}
332-
<h4 class="member-name">${nameHtml}</h4>
333-
${showTitle && member.title ? `<p class="member-title">${member.title[currentLang] || member.title.zh || member.title}</p>` : ''}
334-
</div>
335-
`;
349+
// 如果有主页链接,整个卡片都可点击
350+
if (member.homepage) {
351+
return `
352+
<a href="${member.homepage}" target="_blank" class="member-card member-card-link">
353+
${member.photo ? `<img src="${member.photo}" alt="${name}" class="member-photo">` : ''}
354+
<h4 class="member-name">${name}</h4>
355+
${showTitle && member.title ? `<p class="member-title">${member.title[currentLang] || member.title.zh || member.title}</p>` : ''}
356+
</a>
357+
`;
358+
} else {
359+
return `
360+
<div class="member-card">
361+
${member.photo ? `<img src="${member.photo}" alt="${name}" class="member-photo">` : ''}
362+
<h4 class="member-name">${name}</h4>
363+
${showTitle && member.title ? `<p class="member-title">${member.title[currentLang] || member.title.zh || member.title}</p>` : ''}
364+
</div>
365+
`;
366+
}
336367
}).join('');
337368
}
338369

@@ -562,7 +593,7 @@
562593
<article class="resource-card">
563594
<h3>${card.title}</h3>
564595
<p>${card.desc}</p>
565-
<a class="btn btn-inline" href="#positions?section=${card.id}">${t('positions.detail.link')}</a>
596+
<a class="btn btn-inline" href="javascript:void(0)" onclick="scrollToSection('${card.id}')">${t('positions.detail.link')}</a>
566597
</article>
567598
`).join('')}
568599
</div>

0 commit comments

Comments
 (0)