Skip to content

Commit 37a3454

Browse files
authored
Add files via upload
1 parent 1137da2 commit 37a3454

File tree

4 files changed

+110
-0
lines changed

4 files changed

+110
-0
lines changed

halo.jpg

95.8 KB
Loading

index.html

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Countdown Timer</title>
7+
<link rel="stylesheet" href="style.css" />
8+
<script src="script.js" defer></script>
9+
</head>
10+
<body>
11+
<h1>Your Countdown</h1>
12+
13+
<div class="countdown-container">
14+
<div class="countdown-el days-c">
15+
<p class="big-text" id="days">0</p>
16+
<span>days</span>
17+
</div>
18+
<div class="countdown-el hours-c">
19+
<p class="big-text" id="hours">0</p>
20+
<span>hours</span>
21+
</div>
22+
<div class="countdown-el mins-c">
23+
<p class="big-text" id="mins">0</p>
24+
<span>mins</span>
25+
</div>
26+
<div class="countdown-el seconds-c">
27+
<p class="big-text" id="seconds">0</p>
28+
<span>seconds</span>
29+
</div>
30+
</div>
31+
</body>
32+
</html>

script.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const daysEl = document.getElementById('days');
2+
const hoursEl = document.getElementById('hours');
3+
const minsEl = document.getElementById('mins');
4+
const secondsEl = document.getElementById('seconds');
5+
6+
newYears = window.prompt('Enter a Date for Countdown', '1 Jan 2022');
7+
8+
function countdown() {
9+
const newYearsDate = new Date(newYears);
10+
const currentDate = new Date();
11+
12+
const totalSeconds = (newYearsDate - currentDate) / 1000;
13+
14+
const days = Math.floor(totalSeconds / 3600 / 24);
15+
const hours = Math.floor(totalSeconds / 3600) % 24;
16+
const mins = Math.floor(totalSeconds / 60) % 60;
17+
const seconds = Math.floor(totalSeconds) % 60;
18+
19+
daysEl.innerHTML = days;
20+
hoursEl.innerHTML = formatTime(hours);
21+
minsEl.innerHTML = formatTime(mins);
22+
secondsEl.innerHTML = formatTime(seconds);
23+
}
24+
25+
function formatTime(time) {
26+
return time < 10 ? (`0${time}`) : time;
27+
}
28+
29+
// initial call
30+
countdown();
31+
32+
setInterval(countdown, 1000);

style.css

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;400;600&display=swap");
2+
3+
* {
4+
box-sizing: border-box;
5+
color: antiquewhite;
6+
}
7+
8+
body {
9+
background-image: url("./halo.jpg");
10+
background-size: auto 100%;
11+
background-repeat: no-repeat;
12+
background-position: center center;
13+
display: flex;
14+
flex-direction: column;
15+
align-items: center;
16+
min-height: 100vh;
17+
font-family: "Poppins", sans-serif;
18+
margin: 0;
19+
}
20+
21+
h1 {
22+
font-weight: normal;
23+
font-size: 2.5rem;
24+
margin-top: 10rem;
25+
}
26+
27+
.countdown-container {
28+
display: flex;
29+
flex-wrap: wrap;
30+
justify-content: center;
31+
}
32+
33+
.big-text {
34+
font-weight: bold;
35+
font-size: 4rem;
36+
line-height: 1;
37+
margin: 1rem 1.7rem;
38+
}
39+
40+
.countdown-el {
41+
text-align: center;
42+
}
43+
44+
.countdown-el span {
45+
font-size: 1.2rem;
46+
}

0 commit comments

Comments
 (0)