1
1
<!DOCTYPE html>
2
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 > Clock</ title >
8
- < link rel ="stylesheet " href ="style.css " />
9
- < link rel ="icon " href ="assets/favicon.png ">
10
-
11
- </ head >
12
- < body >
13
- < h2 class ="heading ">
14
- Clock
15
- </ h2 >
16
- < div class ="clock ">
17
- < div class ="hour ">
18
- < div class ="hr " id ="hr "> </ div >
19
- </ div >
20
- < div class ="min ">
21
- < div class ="mn " id ="mn "> </ div >
22
- </ div >
23
- < div class ="sec ">
24
- < div class ="sc " id ="sc "> </ div >
25
- </ div >
3
+
4
+ < head >
5
+ < meta charset ="UTF-8 " />
6
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
7
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
8
+ < title > Clock</ title >
9
+ < link rel ="stylesheet " href ="style.css " />
10
+ < link rel ="icon " href ="assets/favicon.png ">
11
+
12
+ </ head >
13
+
14
+ < body >
15
+ < h2 class ="heading ">
16
+ Clock
17
+ </ h2 >
18
+ < div class ="clock ">
19
+ < div class ="hour ">
20
+ < div class ="hr " id ="hr "> </ div >
21
+ </ div >
22
+ < div class ="min ">
23
+ < div class ="mn " id ="mn "> </ div >
26
24
</ div >
27
-
28
-
29
-
30
- < footer >
31
- < p > < / > with ❤️ by
32
- < a href ="https://swapnilsparsh.github.io/ "> Swapnil Srivastava</ a >
33
- < br >
34
- < a href ="https://github.com/swapnilsparsh/30DaysOfJavaScript " target ="_blank "> #30DaysOfJavaScript
35
- </ a >
36
- </ p >
37
- </ footer >
38
-
39
- < script type ="text/javascript ">
40
- const deg = 6 ;
41
- const hr = document . querySelector ( '#hr' )
42
- const mn = document . querySelector ( '#mn' ) ;
43
- const sc = document . querySelector ( '#sc' ) ;
44
-
45
- setInterval ( ( ) => {
46
- let day = new Date ( ) ;
47
- let hh = day . getHours ( ) * 30 ;
48
- let mm = day . getMinutes ( ) * deg ;
49
- let ss = day . getSeconds ( ) * deg ;
50
-
51
- hr . style . transform = `rotateZ(${ ( hh ) + ( mm / 12 ) } deg)` ;
52
- mn . style . transform = `rotateZ(${ mm } deg)` ;
53
- sc . style . transform = `rotateZ(${ ss } deg)` ;
54
- } )
55
- </ script >
56
- </ body >
57
- </ html >
25
+ < div class ="sec ">
26
+ < div class ="sc " id ="sc "> </ div >
27
+ </ div >
28
+ </ div >
29
+
30
+
31
+
32
+ < footer >
33
+ < p > < / > with ❤️ by
34
+ < a href ="https://swapnilsparsh.github.io/ "> Swapnil Srivastava</ a >
35
+ < br >
36
+ < a href ="https://github.com/swapnilsparsh/30DaysOfJavaScript " target ="_blank "> #30DaysOfJavaScript
37
+ </ a >
38
+ </ p >
39
+ </ footer >
40
+
41
+ < script type ="text/javascript ">
42
+ const deg = 6 ;
43
+ // getting all hands of clock from html through id
44
+ const hr = document . querySelector ( '#hr' )
45
+ const mn = document . querySelector ( '#mn' ) ;
46
+ const sc = document . querySelector ( '#sc' ) ;
47
+
48
+ setInterval ( ( ) => {
49
+ let day = new Date ( ) ;
50
+
51
+ //setting the actual seconds minutes and hour in clock
52
+
53
+ let ms = day . getMilliseconds ( ) * deg ;
54
+ let hh = day . getHours ( ) * 30 ;
55
+ let mm = day . getMinutes ( ) * deg ;
56
+ let ss = day . getSeconds ( ) * deg + ms / 1000 ;
57
+
58
+ //changing the degrees in the style as per the time
59
+
60
+ hr . style . transform = `rotateZ(${ ( hh ) + ( mm / 12 ) } deg)` ;
61
+ mn . style . transform = `rotateZ(${ mm } deg)` ;
62
+ sc . style . transform = `rotateZ(${ ss } deg)` ;
63
+
64
+ } , 1 ) ;
65
+ </ script >
66
+ </ body >
67
+
68
+ </ html >
0 commit comments