File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6161 background : black;
6262 position : absolute;
6363 top : 50% ;
64+ transform-origin : 100% ;
65+ transform : rotate (90deg );
66+ transition : all 0.05s ;
67+ transition-timing-function : cubic-bezier (0 , 2.42 , 0.58 , 1 );
6468 }
6569
6670 </ style >
6771
6872 < script >
73+ const secondHand = document . querySelector ( '.second-hand' ) ;
74+ const minuteHand = document . querySelector ( '.min-hand' ) ;
75+ const hourHand = document . querySelector ( '.hour-hand' ) ;
6976
77+ function setDate ( ) {
78+ const now = new Date ( ) ;
7079
80+ const seconds = now . getSeconds ( ) ;
81+ const secondsDegrees = ( ( seconds / 60 ) * 360 ) + 90 ;
82+ secondHand . style . transform = `rotate(${ secondsDegrees } deg)` ;
83+
84+ const minutes = now . getMinutes ( ) ;
85+ const minutesDegrees = ( ( minutes / 60 ) * 360 ) + 90 ;
86+ minuteHand . style . transform = `rotate(${ minutesDegrees } deg)` ;
87+
88+ const hours = now . getHours ( ) ;
89+ const hoursDegrees = ( ( hours / 12 ) * 360 ) + 90 ;
90+ hourHand . style . transform = `rotate(${ hoursDegrees } deg)` ;
91+ }
92+
93+ setInterval ( setDate , 1000 ) ;
7194 </ script >
7295</ body >
7396</ html >
You can’t perform that action at this time.
0 commit comments