Skip to content

Commit

Permalink
Merge pull request #41 from rutikakengal/#37-issue-Fixed-Top-Scroll-b…
Browse files Browse the repository at this point in the history
…utton-

#37 Top Scroll button Fixed
  • Loading branch information
SUGAM-ARORA authored Jan 5, 2025
2 parents eb44b94 + 7309b57 commit f149520
Showing 1 changed file with 65 additions and 1 deletion.
66 changes: 65 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"
/>
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="styles.css">
<style>
* {
Expand Down Expand Up @@ -226,7 +238,31 @@
.chat-button:hover {
transform: scale(1.1);
background-color: #000;
}
}

/* CSS for Scroll to Top Button */
#scrollBtn {
position: fixed;
bottom: 80px; /* 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: #000; /* Change color on hover */
transform: scale(1.2); /* Slightly enlarge */
}


/* Styles for floating image button */
.image-button {
Expand Down Expand Up @@ -697,6 +733,11 @@ <h2 style="color: black;">What are
<p style="color: #d6a52b;">&copy; 2024 Ajivika™. All rights reserved.</p>
</footer>

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

<!-- Floating Chat Button -->
<button class="chat-button" onclick="window.location.href='./chatbot.html'">
<i class="fas fa-comments"></i>
Expand Down Expand Up @@ -729,5 +770,28 @@ <h2 style="color: black;">What are
setTimeout(showSlides, 2000); // Change image every 2 seconds
}
</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>

0 comments on commit f149520

Please sign in to comment.