Skip to content

Commit

Permalink
added scroll to top feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Palmistry2310 committed Oct 28, 2024
1 parent 120669e commit 087f9e3
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions about.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@
<div id="loading-text">Ready to Explore the World...</div>
</div>
<style>


.scroll-to-top {
position: fixed;
bottom: 30px;
right: 30px;
padding: 10px 15px;
font-size: 20px;
background-color: #007BFF;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
display: none; /* Hidden by default */
z-index: 1000;
}

.scroll-to-top:hover {
background-color: #0056b3;
}


/* Preloader Container */
#preloader {
position: fixed;
Expand Down Expand Up @@ -616,6 +638,10 @@ <h3>PRIYA Ghosal</h3>
}
</style>

<button id="scrollToTopBtn" class="scroll-to-top"></button>



<div class="footer-responsive">

<footer>
Expand Down Expand Up @@ -717,6 +743,26 @@ <h3>Follow Us <div class="underline"><span></span></div>
});
</script>

<script>
// Show the button when the user scrolls down 100px from the top
window.onscroll = function() {
const scrollToTopBtn = document.getElementById('scrollToTopBtn');
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
scrollToTopBtn.style.display = 'block';
} else {
scrollToTopBtn.style.display = 'none';
}
};

// Scroll to the top when the button is clicked
document.getElementById('scrollToTopBtn').addEventListener('click', function() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});

</script>
</body>

</html>

0 comments on commit 087f9e3

Please sign in to comment.