Skip to content

Commit

Permalink
Add a back to top button (#183)
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Cotton <[email protected]>
  • Loading branch information
funnelfiasco authored Feb 6, 2025
1 parent 77e8c8b commit 919e19f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmd/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

Version: devel (not for production use)

<!-- A button for returning to the top of the page -->
<button onclick="toTop()" id="topButton" title="Go to top"
style="display: none; position: fixed; bottom: 20px; right: 30px; border: none; background-color: CornflowerBlue; color: white; cursor: pointer; padding: 10px; border-radius: 10px; font-size: 18px;">to top</button>

<script>
let topButton = document.getElementById("topButton");
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
if (document.documentElement.scrollTop > 50 ) {
topButton.style.display = "block";
} else {
topButton.style.display = "none";
}
}

function toTop() {
document.documentElement.scrollTop = 0;
}
</script>
<!-- That's enough button stuff for now -->

* Contents
{:toc}

Expand Down

0 comments on commit 919e19f

Please sign in to comment.