Skip to content

Commit 4f457c4

Browse files
committed
feat: 优化官网效果
1 parent 6c215f5 commit 4f457c4

File tree

3 files changed

+64
-23
lines changed

3 files changed

+64
-23
lines changed
277 KB
Loading
621 KB
Loading

website/index.html

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
}
139139

140140
.nav-container.fixed {
141-
top: 10px;
141+
top: 0;
142142
padding: 5px 0;
143143
}
144144

@@ -562,27 +562,20 @@
562562
padding: 0;
563563
}
564564

565-
.steps li {
565+
.steps > li {
566566
position: relative;
567-
padding-left: 45px;
568-
margin-bottom: 25px;
567+
counter-increment: step;
569568
}
570569

571-
.steps li::before {
572-
counter-increment: step;
573-
content: counter(step);
574-
position: absolute;
575-
left: 0;
576-
top: 0;
577-
width: 30px;
578-
height: 30px;
579-
background: #4299e1;
580-
color: white;
581-
border-radius: 50%;
570+
.steps > li h3::before {
571+
content: counter(step) ". ";
572+
color: #4299e1;
573+
}
574+
575+
.steps > li h3 {
582576
display: flex;
583577
align-items: center;
584-
justify-content: center;
585-
font-weight: bold;
578+
gap: 8px;
586579
}
587580

588581
.note {
@@ -749,7 +742,7 @@
749742
cursor: zoom-in;
750743
}
751744

752-
/* 固定导航栏容器 */
745+
/* 导航栏容器样式 */
753746
.nav-container {
754747
position: absolute;
755748
left: 0;
@@ -763,21 +756,23 @@
763756

764757
.nav-container.fixed {
765758
position: fixed;
766-
top: 15px;
759+
top: 0;
767760
bottom: auto;
768761
transform: translateY(0);
769762
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.9));
770763
padding: 10px 0;
764+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
771765
}
772766

773767
.nav-container.fixed::before {
774768
content: '';
775769
position: absolute;
770+
top: 0;
776771
left: 0;
777772
right: 0;
778-
top: -10px;
779-
height: 10px;
780-
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
773+
bottom: 0;
774+
backdrop-filter: blur(10px);
775+
z-index: -1;
781776
}
782777

783778
/* 更新仓库链接样式 */
@@ -894,10 +889,14 @@
894889

895890
.collapsible-body img {
896891
max-width: 100%;
892+
height: auto;
897893
border-radius: 8px;
898894
margin: 10px 0;
899895
border: 1px solid rgba(0, 0, 0, 0.1);
900896
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
897+
max-height: 300px; /* 限制图片的最大高度 */
898+
object-fit: contain; /* 保持图片比例 */
899+
cursor: zoom-in; /* 添加放大镜指针 */
901900
}
902901

903902
/* 更新提示框样式 */
@@ -1338,7 +1337,7 @@ <h3>开发调试</h3>
13381337
const closeButton = previewOverlay.querySelector('.close-preview');
13391338

13401339
// 点击图片打开预览
1341-
document.querySelectorAll('.demo-image').forEach(img => {
1340+
document.querySelectorAll('.demo-image, .collapsible-body img').forEach(img => {
13421341
img.addEventListener('click', () => {
13431342
previewImage.src = img.src;
13441343
previewImage.alt = img.alt;
@@ -1427,6 +1426,48 @@ <h3>开发调试</h3>
14271426
}
14281427
});
14291428
});
1429+
1430+
// 折叠面板功能
1431+
document.querySelectorAll('.collapsible-header').forEach(header => {
1432+
header.addEventListener('click', () => {
1433+
const collapsible = header.closest('.collapsible');
1434+
collapsible.classList.toggle('active');
1435+
const content = collapsible.querySelector('.collapsible-content');
1436+
if (collapsible.classList.contains('active')) {
1437+
content.style.maxHeight = content.scrollHeight + "px";
1438+
} else {
1439+
content.style.maxHeight = null;
1440+
}
1441+
});
1442+
});
1443+
1444+
// 处理导航栏固定效果
1445+
const header = document.querySelector('header');
1446+
const navContainer = document.querySelector('.nav-container');
1447+
const headerHeight = header.offsetHeight;
1448+
let lastScrollTop = 0;
1449+
1450+
function handleScroll() {
1451+
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
1452+
1453+
if (scrollTop > headerHeight / 3) {
1454+
header.classList.add('scrolled');
1455+
} else {
1456+
header.classList.remove('scrolled');
1457+
}
1458+
1459+
// 处理导航栏固定
1460+
if (scrollTop > headerHeight / 2) {
1461+
navContainer.classList.add('fixed');
1462+
} else {
1463+
navContainer.classList.remove('fixed');
1464+
}
1465+
1466+
lastScrollTop = scrollTop;
1467+
}
1468+
1469+
window.addEventListener('scroll', handleScroll);
1470+
handleScroll(); // 初始化状态
14301471
</script>
14311472
</body>
14321473
</html>

0 commit comments

Comments
 (0)