Skip to content

Commit a9942d5

Browse files
committed
conuntdown timer
1 parent 636f51a commit a9942d5

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed
44.1 KB
Loading

23. Countdown Timer/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 defer src="script.js"></script>
9+
</head>
10+
<body>
11+
<div class="container">
12+
<p id="countDown">30:00</p>
13+
</div>
14+
</body>
15+
</html>

23. Countdown Timer/script.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const startMinutes = 30;
2+
const startHour = 1;
3+
4+
let time = startMinutes * 60;
5+
let countDown = document.getElementById("countDown");
6+
7+
setInterval(countdown, 1000);
8+
9+
function countdown() {
10+
let hour = (new Date()).getHours();
11+
let minutes = Math.floor(time / 60);
12+
let seconds = time % 60;
13+
seconds = seconds < 10 ? "0" + seconds : seconds;
14+
countDown.innerHTML = hour + ":" + minutes + ":" + seconds;
15+
time--;
16+
}

23. Countdown Timer/style.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
* {
2+
margin: 0;
3+
padding: 0;
4+
box-sizing: border-box;
5+
}
6+
7+
.container {
8+
display: flex;
9+
flex-direction: column;
10+
justify-content: center;
11+
align-items: center;
12+
height: 100vh;
13+
width: 100%;
14+
background-color: #222;
15+
color: #fff;
16+
font-family: cursive;
17+
font-size: 10em;
18+
text-align: center;
19+
font-weight: 700;
20+
}

0 commit comments

Comments
 (0)