File tree Expand file tree Collapse file tree 1 file changed +30
-4
lines changed Expand file tree Collapse file tree 1 file changed +30
-4
lines changed Original file line number Diff line number Diff line change 3
3
< head >
4
4
< meta charset ="UTF-8 ">
5
5
< title > JS + CSS Clock</ title >
6
- < link rel ="icon " href ="https://fav.farm/🔥 " />
6
+ < link rel ="icon " href ="https://fav.farm/✅ " />
7
7
</ head >
8
8
< body >
9
9
63
63
background : black;
64
64
position : absolute;
65
65
top : 50% ;
66
+ transform-origin : 100% ;
67
+ transform : rotate (90deg );
68
+ transition : all 0.05s ;
69
+ transition-timing-function : cubic-bezier (0.1 , 2.7 , 0.58 , 1 );
66
70
}
71
+ </ style >
67
72
68
- </ style >
69
73
70
- < script >
74
+ < script >
75
+ const secondHand = document . querySelector ( '.second-hand' ) ;
76
+ const minsHand = document . querySelector ( '.min-hand' ) ;
77
+ const hourHand = document . querySelector ( '.hour-hand' ) ;
71
78
79
+ function setDate ( ) {
80
+ const now = new Date ( ) ;
72
81
73
- </ script >
82
+ const seconds = now . getSeconds ( ) ;
83
+ const secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
84
+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)` ;
85
+
86
+ const mins = now . getMinutes ( ) ;
87
+ const minsDegrees = ( ( mins / 60 ) * 360 ) + ( ( seconds / 60 ) * 6 ) + 90 ;
88
+ minsHand . style . transform = `rotate(${ minsDegrees } deg)` ;
89
+
90
+ const hour = now . getHours ( ) ;
91
+ const hourDegrees = ( ( hour / 12 ) * 360 ) + ( ( mins / 60 ) * 30 ) + 90 ;
92
+ hourHand . style . transform = `rotate(${ hourDegrees } deg)` ;
93
+ }
94
+
95
+ setInterval ( setDate , 1000 ) ;
96
+
97
+ setDate ( ) ;
98
+
99
+ </ script >
74
100
</ body >
75
101
</ html >
You can’t perform that action at this time.
0 commit comments