Skip to content

Commit 3f4727b

Browse files
authored
Merge pull request #27 from tajulafreen/Countdown_Timer
50Projects-HTML-CSS-JavaScript : Countdown Timer
2 parents ce7519f + 901cd3a commit 3f4727b

File tree

5 files changed

+118
-0
lines changed

5 files changed

+118
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,17 @@ In order to run this project you need:
276276
</details>
277277
</li>
278278

279+
<li>
280+
<details>
281+
<summary>Countdown Timer</summary>
282+
<p>The Countdown Timer is an intuitive and visually appealing tool built using HTML, CSS, and JavaScript. This project allows users to set a countdown to a specific event or deadline, providing a real-time display of the remaining days, hours, minutes, and seconds. It's a great project for beginners to practice and enhance their web development skills.</p>
283+
<ul>
284+
<li><a href="https://tajulafreen.github.io/50Projects-HTML-CSS-JavaScript/Source-Code/CountdownTimer/">Live Demo</a></li>
285+
<li><a href="https://github.com/tajulafreen/50Projects-HTML-CSS-JavaScript/tree/main/Source-Code/CountdownTimer">Source</a></li>
286+
</ul>
287+
</details>
288+
</li>
289+
279290
</ol>
280291

281292
<p align="right">(<a href="#readme-top">back to top</a>)</p>
97.5 KB
Loading

Source-Code/CountdownTimer/index.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
</head>
9+
<body>
10+
<h1>EID CELEBRATIONS</h1>
11+
12+
<div class="container">
13+
<div class="countdown days-c">
14+
<p class="big-text" id="days">0</p>
15+
<span>days</span>
16+
</div>
17+
<div class="countdown hours-c">
18+
<p class="big-text" id="hours">0</p>
19+
<span>hours</span>
20+
</div>
21+
<div class="countdown mins-c">
22+
<p class="big-text" id="mins">0</p>
23+
<span>mins</span>
24+
</div>
25+
<div class="countdown seconds-c">
26+
<p class="big-text" id="seconds">0</p>
27+
<span>seconds</span>
28+
</div>
29+
</div>
30+
31+
<script src="script.js"></script>
32+
</body>
33+
</html>

Source-Code/CountdownTimer/script.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
document.addEventListener('DOMContentLoaded', () => {
2+
const daysEl = document.getElementById('days');
3+
const hoursEl = document.getElementById('hours');
4+
const minsEl = document.getElementById('mins');
5+
const secondsEl = document.getElementById('seconds');
6+
7+
const eid = '30 Mar 2025';
8+
const formatTime = (time) => (time < 10 ? `0${time}` : time);
9+
const countdown = () => {
10+
const EidDate = new Date(eid);
11+
const currentDate = new Date();
12+
13+
const totalSeconds = (EidDate - currentDate) / 1000;
14+
15+
const days = Math.floor(totalSeconds / 3600 / 24);
16+
const hours = Math.floor(totalSeconds / 3600) % 24;
17+
const mins = Math.floor(totalSeconds / 60) % 60;
18+
const seconds = Math.floor(totalSeconds) % 60;
19+
20+
daysEl.innerHTML = days;
21+
hoursEl.innerHTML = formatTime(hours);
22+
minsEl.innerHTML = formatTime(mins);
23+
secondsEl.innerHTML = formatTime(seconds);
24+
};
25+
26+
// initial call
27+
countdown();
28+
29+
setInterval(countdown, 1000);
30+
});

Source-Code/CountdownTimer/style.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
* {
2+
box-sizing: border-box;
3+
}
4+
5+
body {
6+
background-image: url(./assets/eid.jpg);
7+
background-size: cover;
8+
background-position: center center;
9+
background-attachment: fixed;
10+
background-repeat: no-repeat;
11+
font-family: "Roboto", sans-serif;
12+
margin-top: 4rem;
13+
color: #c9cc6b;
14+
}
15+
16+
.container {
17+
display: flex;
18+
justify-content: center;
19+
align-items: center;
20+
margin-top: 10rem;
21+
flex-wrap: wrap;
22+
}
23+
24+
h1 {
25+
font-size: 4rem;
26+
margin-top: 1rem;
27+
text-align: center;
28+
flex-wrap: wrap;
29+
}
30+
31+
.big-text {
32+
font-weight: bold;
33+
font-size: 8rem;
34+
line-height: 0.5;
35+
margin: 1rem 2rem;
36+
}
37+
38+
.countdown {
39+
text-align: center;
40+
}
41+
42+
.countdown span {
43+
font-size: 2rem;
44+
}

0 commit comments

Comments
 (0)