Skip to content

Commit 86471cb

Browse files
authored
Merge pull request #18 from RitaRossweiss/main
✨右下角添加返回顶部按钮;移动Github徽标到右上角
2 parents ba1979e + cd4946c commit 86471cb

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

Web/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ <h1 id="title">这就是VV</h1>
6767
</svg>
6868
</a>
6969
</footer>
70+
71+
<footer id="backToTop" class="back-to-top" title="返回顶部">
72+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none" stroke="currentColor" stroke-width="2">
73+
<path d="M17 15l-5-5-5 5"/>
74+
</svg>
75+
</footer>
7076

7177
<script src="db_search.js"></script>
7278
<script src="script.js"></script>

Web/script.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,4 +706,20 @@ function handleCardClick(result) {
706706
break
707707
}
708708
}
709-
}
709+
}
710+
// backToTop
711+
var button = document.getElementById('backToTop');
712+
button.style.display = 'none';
713+
window.addEventListener('scroll', function() {
714+
if (window.pageYOffset > 200) {
715+
button.style.display = 'block';
716+
} else {
717+
button.style.display = 'none';
718+
}
719+
});
720+
button.addEventListener('click', function() {
721+
window.scrollTo({
722+
top: 0,
723+
behavior: 'smooth'
724+
});
725+
});

Web/style.css

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,14 @@ input:focus {
311311
}
312312

313313
.site-footer {
314-
text-align: center;
315-
padding: 2rem 0;
314+
position: fixed;
315+
top: 0.5rem;
316+
right: 0.5rem;
317+
padding: 1rem;
318+
z-index: 1000;
319+
text-align: right;
320+
backdrop-filter: blur(20px);
321+
-webkit-mask: radial-gradient(closest-side circle, #000 40%, transparent 100%);
316322
}
317323

318324
.github-link {
@@ -325,6 +331,17 @@ input:focus {
325331
opacity: 1;
326332
}
327333

334+
.back-to-top{
335+
position: fixed;
336+
bottom: 0.5rem;
337+
right: 0.5rem;
338+
padding: 1rem;
339+
z-index: 1000;
340+
text-align: right;
341+
backdrop-filter: blur(20px);
342+
-webkit-mask: radial-gradient(closest-side circle, #000 40%, transparent 100%);
343+
}
344+
328345
@media (max-width: 640px) {
329346
.main-content {
330347
padding: 0 1rem;
@@ -780,4 +797,4 @@ button {
780797
.error-message:active {
781798
background-color: var(--gray-100);
782799
}
783-
}
800+
}

0 commit comments

Comments
 (0)