File tree Expand file tree Collapse file tree 3 files changed +108
-0
lines changed Expand file tree Collapse file tree 3 files changed +108
-0
lines changed Original file line number Diff line number Diff line change
1
+ const days = document . getElementById ( 'days' ) ;
2
+ const hours = document . getElementById ( 'hours' ) ;
3
+ const minutes = document . getElementById ( 'minutes' ) ;
4
+ const seconds = document . getElementById ( 'seconds' ) ;
5
+
6
+
7
+
8
+ const karmaDateTime = new Date ( 'May 21 2022 00:00:00' ) ;
9
+
10
+
11
+ function updateCountdowntime ( ) {
12
+ const currentTime = new Date ( ) ;
13
+ const diff = karmaDateTime - currentTime ;
14
+ const d = Math . floor ( diff / 1000 / 60 / 60 / 24 ) ;
15
+ const h = Math . floor ( diff / 1000 / 60 / 60 ) % 24 ;
16
+ const m = Math . floor ( diff / 1000 / 60 ) % 60 ;
17
+ const s = Math . floor ( diff / 1000 ) % 60 ;
18
+ if ( currentTime === karmaDateTime ) {
19
+ clearInterval ( ) ;
20
+ days . innerHTML = 00 ;
21
+ hours . innerHTML = 00 ;
22
+ minutes . innerHTML = 00 ;
23
+ seconds . innerHTML = 00 ;
24
+
25
+ }
26
+ days . innerHTML = d ;
27
+ hours . innerHTML = h < 10 ? '0' + h :h ;
28
+ minutes . innerHTML = m < 10 ? '0' + m :m ;
29
+ seconds . innerHTML = s < 10 ? '0' + s :s ;
30
+
31
+ }
32
+
33
+ setInterval ( updateCountdowntime , 1000 ) ;
34
+ updateCountdowntime ( ) ;
Original file line number Diff line number Diff line change
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 > CountDown</ title >
8
+ < link rel ="stylesheet " href ="style.css ">
9
+ </ head >
10
+
11
+ < body >
12
+ < div class ="box ">
13
+ < div class ="countdown " id ="countdown ">
14
+ < div class ="time ">
15
+ < h2 id ="days "> </ h2 >
16
+ < small > Days</ small >
17
+ </ div >
18
+ < div class ="time ">
19
+ < h2 id ="hours "> </ h2 >
20
+ < small > Hours</ small >
21
+ </ div >
22
+ < div class ="time ">
23
+ < h2 id ="minutes "> </ h2 >
24
+ < small > Minutes</ small >
25
+ </ div >
26
+ < div class ="time ">
27
+ < h2 id ="seconds "> </ h2 >
28
+ < small > Seconds</ small >
29
+ </ div >
30
+ </ div >
31
+ </ div >
32
+ </ body >
33
+ < script src ="/app.js "> </ script >
34
+ </ html >
Original file line number Diff line number Diff line change
1
+
2
+ @import url ('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;700&display=swap' );
3
+
4
+ * {
5
+ box-sizing : border-box;
6
+ }
7
+ body {
8
+ align-items : center;
9
+ justify-content : center;
10
+ font-family : "Poppins" , sans-serif;
11
+ display : flex;
12
+ text-align : center;
13
+ margin : 25em ;
14
+ overflow : hidden;
15
+
16
+ width : auto;
17
+ border : 5px solid;
18
+ height : 20em ;
19
+ border-radius : 1em
20
+
21
+ }
22
+
23
+
24
+ .countdown {
25
+ display : flex;
26
+ transform : scale (2 );
27
+ }
28
+ .time {
29
+ display : flex;
30
+ align-items : center;
31
+ flex-direction : column;
32
+ justify-content : center;
33
+ margin : 15px ;
34
+ }
35
+ .time h2 {
36
+ font-weight : bold;
37
+ font-size : 36px ;
38
+ line-height : 1 ;
39
+ margin : 0 0 5px ;
40
+ }
You can’t perform that action at this time.
0 commit comments