Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Added Scroll Button to Blog Page πŸš€ #208

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 24 additions & 1 deletion blog.css
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,27 @@ footer {

footer li:hover {
transform: scale(1.1);
}
}

/* CSS for Scroll to Top Button */
#scrollBtn {
position: fixed;
bottom: 95px; /* Place closer to the bottom */
right: 30px; /* Place closer to the right */
display: none; /* Initially hidden */
background-color: #d6a52b;
color: white;
border: none;
border-radius: 50%;
padding: 15px;
font-size: 18px;
cursor: pointer;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
z-index: 1000; /* Ensure visibility above other elements */
transition: background-color 0.3s ease, transform 0.3s ease;
}

#scrollBtn:hover {
background-color: #FFD700; /* Change color on hover */
transform: scale(1.2); /* Slightly enlarge */
}
30 changes: 30 additions & 0 deletions blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
<link rel="stylesheet" href="blog.css">
</head>
<body>

<!-- Top scroll button -->
<button id="scrollBtn" title="Go to top">
<i class="fa-solid fa-arrow-up fa-lg"></i>
</button>

<div id="cursor"></div>
<!-- Navigation -->
<nav class="navbar">
Expand Down Expand Up @@ -388,5 +394,29 @@ <h3>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js" integrity="sha512-7eHRwcbYkK4d9g/6tD/mhkf++eoTHwpNM9woBxtPUBWm67zeAfFC+HrdoE2GanKeocly/VxeLvIqwvCdk7qScg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="index.js"></script>

<script>
// Get the button element
const scrollBtn = document.getElementById('scrollBtn');

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

// Scroll to the top of the page when the button is clicked
scrollBtn.onclick = function () {
window.scrollTo({
top: 0,
behavior: "smooth"
});
};

</script>

</body>
</html>