Skip to content

Commit 177a6b5

Browse files
Issue with Duplicate Scripts ,no opening section , Missing Scroll Top Solved
1 parent 3569eca commit 177a6b5

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

index.html

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ <h3 class="review-name">Sara Ahmed</h3>
360360
<p>Message Delivered</p>
361361
</div>
362362
</div>
363-
</section>
363+
364364
</main>
365365

366366
<footer class="footer">
@@ -371,22 +371,7 @@ <h3 class="review-name">Sara Ahmed</h3>
371371
</footer>
372372
<button id="scrollToTopBtn" title="Go to top"></button>
373373
<script src="script.js"></script>
374-
<script>
375-
const toggle = document.getElementById('darkModeToggle');
376-
const body = document.body;
377-
const icon = document.getElementById('themeIcon');
378-
379-
// Load preference
380-
const savedTheme = localStorage.getItem('theme');
381-
if (savedTheme === 'dark') {
382-
body.classList.add('dark-theme');
383-
icon.textContent = '☀️'; // Sun in dark mode
384-
} else {
385-
icon.textContent = '🌙'; // Moon in light mode
386-
}
387-
388-
389-
<script src="script.js"></script>
374+
390375
</body>
391376
</html>
392377

script.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,4 +377,20 @@ function validateForm() {
377377
grabCursor: true,
378378
speed: 600,
379379
});
380-
380+
381+
382+
//Scroll to top functionality
383+
const scrollToTopBtn = document.getElementById("scrollToTopBtn");
384+
385+
// Show button when user scrolls down
386+
window.addEventListener("scroll", () => {
387+
scrollToTopBtn.style.display = window.scrollY > 300 ? "block" : "none";
388+
});
389+
390+
// Scroll to top smoothly
391+
scrollToTopBtn.addEventListener("click", () => {
392+
window.scrollTo({
393+
top: 0,
394+
behavior: "smooth"
395+
});
396+
});

style.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,3 +1162,25 @@ body.dark-theme button:hover {
11621162
}
11631163

11641164

1165+
#scrollToTopBtn {
1166+
position: fixed;
1167+
bottom: 2rem;
1168+
right: 2rem;
1169+
z-index: 999;
1170+
background-color: #667eea;
1171+
color: white;
1172+
border: none;
1173+
outline: none;
1174+
padding: 0.75rem 1rem;
1175+
border-radius: 50%;
1176+
font-size: 1.25rem;
1177+
cursor: pointer;
1178+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
1179+
display: none;
1180+
transition: background 0.3s ease, transform 0.3s ease;
1181+
}
1182+
1183+
#scrollToTopBtn:hover {
1184+
background-color: #5a67d8;
1185+
transform: scale(1.1);
1186+
}

0 commit comments

Comments
 (0)