Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4b6a4cc

Browse files
committed
complete day 2
1 parent d12077d commit 4b6a4cc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

02 - JS and CSS Clock/index-START.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,35 @@
6262
background: black;
6363
position: absolute;
6464
top: 50%;
65+
transform-origin: 100%;
66+
transform: rotate(90deg);
67+
transition: all 0.05s ease-in-out;
68+
transition-timing-function: cubic-bezier(0, 2.6, 0.58, 1);
6569
}
6670

6771
</style>
6872

6973
<script>
74+
const secondHand = document.querySelector('.second-hand');
75+
const minHand = document.querySelector('.min-hand');
76+
const hourHand = document.querySelector('.hour-hand');
7077

78+
function setDate() {
79+
const now = new Date();
80+
const seconds = now.getSeconds();
81+
const secondsDegrees = (( seconds / 60 ) * 360) + 90;
82+
secondHand.style.transform = `rotate(${secondsDegrees}deg`;
83+
84+
const mins = now.getMinutes();
85+
const minsDegrees = (( mins / 60 ) * 360) + 90;
86+
minHand.style.transform = `rotate(${minsDegrees}deg`;
87+
88+
const hours = now.getHours();
89+
const hoursDegrees = (( hours / 60 ) * 360) + 90;
90+
hourHand.style.transform = `rotate(${hoursDegrees}deg`;
91+
}
92+
93+
setInterval(setDate, 1000);
7194

7295
</script>
7396
</body>

0 commit comments

Comments
 (0)