-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathindex.html
69 lines (63 loc) · 2.54 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="https://www.svgrepo.com/show/123948/timer.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="A simple timer application to track time efficiently." />
<meta name="keywords" content="timer, stopwatch, time tracking" />
<title>Counter App</title>
</head>
<body>
<button id="scrollToTopBtn" style="display:none;">
↑ <!-- Arrow Up -->
</button>
<style>
#scrollToTopBtn {
background-color: rgba(128, 128, 128, 0.7); /* Semi-transparent grey */
color: white;
border: none;
border-radius: 50%; /* Fully rounded */
width: 50px; /* Equal width and height for a perfect circle */
height: 50px; /* Equal width and height for a perfect circle */
cursor: pointer;
font-size: 20px;
position: fixed;
bottom: 20px;
right: 20px;
z-index: 1000;
transition: opacity 0.3s, transform 0.3s;
opacity: 0;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
display: flex;
align-items: center;
justify-content: center;
}
#scrollToTopBtn:hover {
transform: scale(1.1);
background-color: rgba(96, 96, 96, 0.8);
}
</style>
<script>
const scrollToTopBtn = document.getElementById("scrollToTopBtn");
// Show or hide the button based on scroll position
window.onscroll = function () {
if (document.body.scrollTop > 200 || document.documentElement.scrollTop > 200) {
scrollToTopBtn.style.opacity = "1"; // Make button visible
scrollToTopBtn.style.display = "flex"; // Ensure it is displayed
} else {
scrollToTopBtn.style.opacity = "0"; // Make button hidden
setTimeout(() => {
scrollToTopBtn.style.display = "none"; // Hide it after fading out
}, 300); // Match with CSS transition duration
}
};
// Scroll to the top when the button is clicked
scrollToTopBtn.onclick = function () {
window.scrollTo({ top: 0, behavior: 'smooth' }); // Smooth scroll to top
};
</script>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>