Skip to content

Commit

Permalink
bottom to top functionality added (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ansh101112 authored Jul 12, 2024
1 parent 1d4dc3b commit cd375cf
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@
background-color: #0056b3; /* Change this to your desired active background color */
border-radius: 4px;
}
#back-to-top {
position: fixed;
bottom: 20px;
right: 20px;
display: none;
background-color: #007bff;
color: white;
border: none;
padding: 10px;
border-radius: 50%;
font-size: 18px;
cursor: pointer;
}
#back-to-top:hover {
background-color: #0056b3;
}
</style>
</head>

Expand Down Expand Up @@ -272,7 +288,7 @@ <h2 class="card-title">How to Create a GitHub Account</h2>
</div>
</div>
</div>

<button id="back-to-top"><i class="fa fa-chevron-up"></i></button>
<!-- Site footer -->
<footer class="site-footer">
<div class="container">
Expand Down Expand Up @@ -393,6 +409,23 @@ <h6>Quick Links</h6>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="./ScrollToTop.js"></script>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
const backToTopButton = document.getElementById('back-to-top');
window.addEventListener('scroll', () => {
if (window.scrollY > 300) {
backToTopButton.style.display = 'block';
} else {
backToTopButton.style.display = 'none';
}
});

backToTopButton.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function () {
fetch('data.json')
Expand Down Expand Up @@ -426,3 +459,5 @@ <h2 class="card-title">${post.title}</h2>
</body>

</html>


0 comments on commit cd375cf

Please sign in to comment.