Skip to content

Commit

Permalink
Merge pull request #48 from Biswa-bob/scroll_button
Browse files Browse the repository at this point in the history
Added : scroll button
  • Loading branch information
sameersrivastava13 authored Jul 16, 2021
2 parents 0652a3e + a09f025 commit 1c0d9e9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
33 changes: 33 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ <h1>Vaccine Tracker</h1>
</div>
</div>

<!-- Scroll Up Button -->
<button onclick="topFunction()" id="myBtn" title="Go to top">
<i class="fa fa-chevron-circle-up"></i>
</button>

<!-- brands -->
<div class="brands">
<div class="small-container">
Expand Down Expand Up @@ -286,5 +291,33 @@ <h3>Follow Us</h3>
}
}
</script>

<!-- Script for Scroll Button -->
<script>
//Get the button
var mybutton = document.getElementById("myBtn");

// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function () {
scrollFunction();
};

function scrollFunction() {
if (
document.body.scrollTop > 20 ||
document.documentElement.scrollTop > 20
) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}

// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
</script>
</body>
</html>
19 changes: 19 additions & 0 deletions static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,25 @@ ul {
.copyright {
text-align: center;
}
#myBtn {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
font-size: 18px;
border: none;
outline: none;
background-color: rgba(14, 105, 117, 0.6);
color: white;
cursor: pointer;
padding: 15px;
border-radius: 4px;
}

#myBtn:hover {
background-color: #555;
}

/* --------------media query for menu------------------ */

Expand Down

0 comments on commit 1c0d9e9

Please sign in to comment.