Skip to content

Commit

Permalink
Fixed scroll on top button PriyaGhosal#340
Browse files Browse the repository at this point in the history
  • Loading branch information
devarsheecodess committed Oct 9, 2024
1 parent f8bfa39 commit e4523ac
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
14 changes: 10 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@
<div id="progressBar"></div>
</div>

<button id="scrollTopBtn" class="scroll-top-btn">
<i class="fa-solid fa-arrow-up"></i>
</button>


<!-- Google Translate Button -->
<div class="translate-container">
Expand Down Expand Up @@ -842,6 +840,14 @@ <h3 class="reviewer-name">Aditi Patel</h3>
</button>
</div>
</a>
<div class="fixed bottom-0 right-2 scroll-container" id="scrolltothetop">
<button class="scroll-button group">
<span class="tooltip-text-scroll">
<i class="fa-solid fa-arrow-up"></i>
</span>
</button>
</div>
</a>

<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>

Expand Down Expand Up @@ -916,7 +922,7 @@ <h2>Exclusive Deals and Offers!</h2>
toggleScrollTopButton();
};

const scrollTopBtn = document.getElementById("scrollTopBtn");
const scrollTopBtn = document.getElementById("scrolltothetop");

function toggleScrollTopButton() {
if (
Expand Down
34 changes: 23 additions & 11 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,34 @@ body {
transition: width 0.2s ease;
}

.scroll-top-btn {
position: fixed; /* Fixed position */
bottom: 20px; /* Distance from the bottom of the viewport */
right: 80px; /* Adjust this value to move the button left */
background-color: #007bff;
.scroll-container {
position: fixed;
bottom: 90px; /* Adjust as needed */
right: 20px; /* Adjust as needed */
z-index: 1000; /* Ensure it appears above other elements */
}

.scroll-button {
background-color: #007bff; /* Change to your preferred color */
color: white;
border: none;
padding: 10px 17px;
cursor: pointer;
border-radius: 50%;
display: none; /* Initially hidden */
z-index: 1000; /* Ensure it appears above other content */
padding: 5px; /* Smaller padding */
cursor: pointer;
position: relative;
width: 50px; /* Adjusted size */
height: 50px; /* Adjusted size */
}

.scroll-top-btn:hover {
background-color: #2c445e;
.tooltip-text-scroll{
position: absolute;
bottom: 10%; /* Position above the button */
right: 50%;
transform: translateX(50%);
color: #fff; /* Tooltip text color */
padding: 5px;
border-radius: 5px;
white-space: nowrap; /* Prevent text from wrapping */
}

h1 {
Expand Down

0 comments on commit e4523ac

Please sign in to comment.