Skip to content

Commit 07389c4

Browse files
author
Mateusz Kaczmarek
committed
JS30 wesbos#2
1 parent 5c81292 commit 07389c4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
font-size: 10px;
2626
}
2727

28+
span {
29+
color: red;
30+
text-transform: uppercase;
31+
font-size: 10px;
32+
}
33+
2834
body {
2935
font-size: 2rem;
3036
display:flex;
@@ -61,13 +67,35 @@
6167
background:black;
6268
position: absolute;
6369
top:50%;
70+
transform-origin: 100%;
71+
transform: rotate(90deg);
72+
transition: all 0.2s cubic-bezier(0.56, 1.71, 0.25, 1)
6473
}
6574

6675
</style>
6776

6877
<script>
78+
const secondHand = document.querySelector('.second-hand');
79+
const minHand = document.querySelector('.min-hand');
80+
const hourHand = document.querySelector('.hour-hand');
81+
82+
function setDate() {
83+
const now = new Date();
84+
85+
const seconds = now.getSeconds();
86+
const secondsDegrees = (seconds / 60) * 360 + 90;
87+
secondHand.style.transform = "rotate(" + secondsDegrees + "deg)";
88+
89+
const mins = now.getMinutes();
90+
const minDegrees = (mins / 60) * 360 + 90;
91+
minHand.style.transform = "rotate(" + minDegrees + "deg)";
6992

93+
const hours = now.getHours();
94+
const hoursDegrees = (hours / 12) * 360 + 90;
95+
hourHand.style.transform = "rotate(" + hoursDegrees + "deg)";
96+
}
7097

98+
setInterval(setDate, 1000)
7199
</script>
72100
</body>
73101
</html>

0 commit comments

Comments
 (0)