diff options
| author | somhairle <[email protected]> | 2026-04-21 20:40:27 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-05-24 17:24:57 +0800 |
| commit | ad8f9f55ea79a4d587aecc69698808da82de3d62 (patch) | |
| tree | d25c0db712e6f015d850627ff957edea44c64f94 /themes/theme/layout/partials/back_to_top.ejs | |
| download | blog-ad8f9f55ea79a4d587aecc69698808da82de3d62.tar.gz | |
二〇二六年四月二十一日
Diffstat (limited to 'themes/theme/layout/partials/back_to_top.ejs')
| -rw-r--r-- | themes/theme/layout/partials/back_to_top.ejs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/themes/theme/layout/partials/back_to_top.ejs b/themes/theme/layout/partials/back_to_top.ejs new file mode 100644 index 00000000..df413f52 --- /dev/null +++ b/themes/theme/layout/partials/back_to_top.ejs @@ -0,0 +1,24 @@ +<div id="back-to-top" class="back-to-top"> + <i class="icon-arrow-up"></i> +</div> + +<script> + const backToTop = document.getElementById('back-to-top'); + + // 显示/隐藏回到顶部按钮 + window.addEventListener('scroll', () => { + if (window.pageYOffset > 300) { + backToTop.classList.add('show'); + } else { + backToTop.classList.remove('show'); + } + }); + + // 点击回到顶部 + backToTop.addEventListener('click', () => { + window.scrollTo({ + top: 0, + behavior: 'smooth' + }); + }); +</script>
\ No newline at end of file |
