diff --git a/assets/css/bobastyle.css b/assets/css/bobastyle.css index 9d6e4ba..5327d41 100644 --- a/assets/css/bobastyle.css +++ b/assets/css/bobastyle.css @@ -245,6 +245,17 @@ footer { text-align: center; } +#back-to-top { + position: fixed; + float: right; + bottom: 25px; + right: 25px; + background-color: var(--background-3); + border-radius: 100%; + padding: 12px; + display: none; +} + /* Navbar formatting */ @@ -319,6 +330,16 @@ footer { /* Basic elements */ +html { + scroll-behavior: smooth; +} + +@media screen and (prefers-reduced-motion: reduce) { + html { + scroll-behavior: auto; + } +} + body { background-color: var(--background); color: var(--text-normal); diff --git a/assets/js/back-to-top.js b/assets/js/back-to-top.js new file mode 100644 index 0000000..13a65a1 --- /dev/null +++ b/assets/js/back-to-top.js @@ -0,0 +1,8 @@ +const backToTop = document.getElementById("back-to-top"); +window.onscroll = function() { + if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) { + backToTop.style.display = "block"; + } else { + backToTop.style.display = "none"; + } +} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index fb1420f..83ec393 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -4,6 +4,8 @@ {{ partial "head.html" . }}
+ +