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 the scroll up feature #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
44 changes: 44 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@
padding: 20px;
transition: width 0.3s; /* Smooth transition for width change */
}
.scroll-to-top {
position: fixed;
bottom: 65px;
right: 30px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 50%;
padding: 12px 16px;
font-size: 20px;
cursor: pointer;
display: none; /* Hidden by default */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
transition: opacity 0.3s ease;
height: 48px;
width: 48px;
}

.scroll-to-top.show {
display: block; /* Show when the class 'show' is added */
}
</style>

</head>
Expand Down Expand Up @@ -626,5 +647,28 @@ <h1 class="text-xl font-bold p-3">Who to follow</h1>
});

</script>


<button class="scroll-to-top" onclick="scrollToTop()"><img src="up_arrow.png"up" width="32px"></button>

<script>
// Show the button when scrolled down
window.onscroll = function() {
const scrollButton = document.querySelector('.scroll-to-top');
if (document.documentElement.scrollTop > 100) {
scrollButton.classList.add('show');
} else {
scrollButton.classList.remove('show');
}
};

// Scroll to top when the button is clicked
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}
</script>
</body>
</html>
Binary file added up_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.