Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added go to top button #221

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion docs/_layouts/listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ <h1>
{% endunless %}

</div>

<button onclick=topFunction() id="top-Btn">GO TO TOP</button>

<!-- Footer -->
<footer>
Expand Down Expand Up @@ -203,5 +203,21 @@ <h2>Support Our Work</h2>
globalHeader.classList.toggle("active");
event.preventDefault();
}

//go to top button functionality
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
if (document.body.scrollTop > 10 || document.documentElement.scrollTop > 10) {
document.getElementById("top-Btn").style.display = "block";
} else {
document.getElementById("top-Btn").style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}
</script>
</html>
44 changes: 40 additions & 4 deletions docs/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,46 @@ background-image: url(/images/cc-green-210.gif);
margin-left: 100px;
}

footer a {
color: var(--vocabulary-brand-color-turquoise);
/* STYLES FOR GO TO TOP BUTTON */
#top-Btn {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
border: none;
outline: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
padding: 15px 20px;
border-radius: 5px;
font-size: 18px;
transition: all 0.3s ease-in-out;
}

#top-Btn:hover {
transform: scale(1.1);
}

footer .donate a {
color: #000;
#top-Btn {
transition: all 0.3s ease-in-out;
}

@media screen and (max-width: 768px) {
button#top-Btn {
padding: 10px 15px;
font-size: 16px;
}
}

@media screen and (max-width: 480px) {
button#top-Btn {
padding: 8px 12px;
font-size: 14px;
bottom: 10px;
right: 10px;
}
}