Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ <h2>Projects</h2>
</div> <!-- /preview-section -->
</div> <!-- /main-container -->



<!-- Back to Top Button -->
<button id="backToTopBtn" title="Go to top">↑</button>


<footer style="margin-top: 2rem; padding: 1rem 0; text-align: center; font-size: 0.9rem;" class="footer">
<div class="foot">
<p class="footer-text">&copy; 2025. All rights reserved.</p>
Expand Down
22 changes: 22 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,3 +507,25 @@ function clearAndReload() {
sessionStorage.clear();
window.location.reload();
}

//back to top button
// Back to Top Button Functionality
document.addEventListener("DOMContentLoaded", function () {
const backToTopBtn = document.createElement("button");
backToTopBtn.id = "backToTopBtn";
backToTopBtn.title = "Go to top";
backToTopBtn.textContent = "↑";
document.body.appendChild(backToTopBtn);

window.addEventListener("scroll", function () {
if (window.scrollY > 50) {
backToTopBtn.classList.add("show");
} else {
backToTopBtn.classList.remove("show");
}
});

backToTopBtn.addEventListener("click", function () {
window.scrollTo({ top: 0, behavior: "smooth" });
});
});
29 changes: 29 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,32 @@ body.dark .footer-link {
.section {
transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Back to Top Button */
/* Back to Top Button */

#backToTopBtn {
display: none;
position: fixed;
bottom: 40px;
right: 40px;
z-index: 999;
font-size: 20px;
background-color: #3b82f6;
color: #f7f9fc;
border: none;
outline: none;
padding: 12px 16px;
border-radius: 50%;
cursor: pointer;
box-shadow: 0 4px 8px rgba(0,0,0,0.3);
transition: opacity 0.3s ease;
opacity: 0;
}
#backToTopBtn.show {
display: block;
opacity: 1;
}
#backToTopBtn:hover {
background-color: #1e40af;
}