Skip to content

Commit

Permalink
Merge pull request #1801 from Sushil010/feat/added-scroll-up-button
Browse files Browse the repository at this point in the history
feat: added-scroll-up-button
  • Loading branch information
samarth-6 authored Oct 31, 2024
2 parents 69eb9dd + 654f2f2 commit 1d6f580
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions about.html
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,74 @@ <h3>PRIYA Ghosal</h3>
}
</style>

<!-- Scroll to top button -->
<button id="scrollToTopBtn" title="Go to top">
<i class="fas fa-arrow-up"></i>
</button>

<style>
#scrollToTopBtn {
position: fixed;
bottom: 30px;
right: 30px;
width: 50px;
height: 50px;
background-color: #000;
color: #fff;
border: none;
border-radius: 50%;
cursor: pointer;
display: none;
font-size: 20px;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
transition: all 0.3s ease;
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
}

#scrollToTopBtn:hover {
background-color: #333;
transform: translateY(-5px);
box-shadow: 0 6px 15px rgba(0,0,0,0.2);
}

#scrollToTopBtn i {
transition: transform 0.3s ease;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

#scrollToTopBtn:hover i {
transform: translate(-50%, -50%) translateY(-3px);
}
</style>

<script>
// Scroll to top functionality
const scrollToTopBtn = document.getElementById("scrollToTopBtn");

// Show button when user scrolls down 300px
window.onscroll = function() {
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 300) {
scrollToTopBtn.style.display = "block";
} else {
scrollToTopBtn.style.display = "none";
}
};

// Smooth scroll to top when button is clicked
scrollToTopBtn.addEventListener("click", function() {
window.scrollTo({
top: 0,
behavior: "smooth"
});
});
</script>

<div class="footer-responsive">

<footer>
Expand Down

0 comments on commit 1d6f580

Please sign in to comment.