Skip to content

Commit 50abc8b

Browse files
committed
JavaScript CountDown
0 parents  commit 50abc8b

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

css/style.css

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
*{
2+
margin: 0;
3+
padding: 0;
4+
box-sizing: border-box;
5+
}
6+
body{
7+
font-family: 'Lato', sans-serif;
8+
}
9+
html{
10+
font-size: 62.5%;
11+
}
12+
.coming_soon{
13+
min-height: 100vh;
14+
display: flex;
15+
justify-content: center;
16+
align-items: center;
17+
flex-direction: column;
18+
}
19+
h2{
20+
font-size: 6rem;
21+
font-weight: bold;
22+
padding: 3rem;
23+
text-transform: capitalize;
24+
}
25+
h3{
26+
font-size: 1.6rem;
27+
text-transform: capitalize;
28+
}
29+
.countdown{
30+
display: flex;
31+
justify-content: space-around;
32+
text-align: center;
33+
}
34+
.waiting{
35+
height: 50vh;
36+
}
37+
.day,.hour,.minute,.second{
38+
font-size: 3rem;
39+
}

img/undraw_time_management_30iu.svg

Lines changed: 1 addition & 0 deletions
Loading

index.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
<link rel="stylesheet" href="css/style.css">
9+
<link rel="preconnect" href="https://fonts.googleapis.com">
10+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
11+
<link href="https://fonts.googleapis.com/css2?family=Lato&display=swap" rel="stylesheet">
12+
</head>
13+
<body>
14+
<section class="coming_soon">
15+
<div>
16+
<h2>we are opening up soon!</h2>
17+
<div class="countdown">
18+
<div class="container_day">
19+
<h3 class="day">time</h3>
20+
<h3>day</h3>
21+
</div>
22+
<div class="container_hour">
23+
<h3 class="hour">time</h3>
24+
<h3>hour</h3>
25+
</div>
26+
<div class="container_minute">
27+
<h3 class="minute">time</h3>
28+
<h3>minute</h3>
29+
</div>
30+
<div class="container_second">
31+
<h3 class="second">time</h3>
32+
<h3>second</h3>
33+
</div>
34+
</div>
35+
</div>
36+
<img src="img/undraw_time_management_30iu.svg" alt="" class="waiting">
37+
</section>
38+
<script src="js/main.js"></script>
39+
</body>
40+
</html>

js/main.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const countdown = () => {
2+
const countDate = new Date("Jan 1, 2022 00:00:00").getTime();
3+
const now = new Date().getTime();
4+
const gap = countDate - now;
5+
// how does time work?
6+
const second = 1000;
7+
const minute = second * 60;
8+
const hour = minute * 60;
9+
const day = hour * 24;
10+
// calculate the shit
11+
const textDay = Math.floor(gap / day);
12+
const textHour = Math.floor(gap % day / hour);
13+
const textMinute = Math.floor(gap % hour / minute);
14+
const textSecond = Math.floor(gap % minute / second);
15+
document.querySelector(".day").innerHTML = textDay;
16+
document.querySelector(".hour").innerHTML = textHour;
17+
document.querySelector(".minute").innerHTML = textMinute;
18+
document.querySelector(".second").innerHTML = textSecond;
19+
};
20+
setInterval(countdown, 1000);

0 commit comments

Comments
 (0)