Skip to content

Commit 1a0526c

Browse files
committed
Day wesbos#2 done.
1 parent 153cf2a commit 1a0526c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,36 @@
6262
background: black;
6363
position: absolute;
6464
top: 50%;
65+
transform-origin: 100%; /*100% to make it in the origin*/
66+
transform: rotate(90deg);
67+
transition: all 0.05s;
68+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
69+
6570
}
6671

6772
</style>
6873

6974
<script>
75+
const secondHand = document.querySelector('.second-hand');
76+
const minHand = document.querySelector('.min-hand');
77+
const hourHand = document.querySelector('.hour-hand');
78+
79+
function setDate() {
80+
const now = new Date();
81+
82+
const seconds = now.getSeconds();
83+
const secondDegrees = (seconds * 6) + 90;
84+
secondHand.style.transform=`rotate(${secondDegrees}deg)`;
7085

86+
const mins = now.getMinutes();
87+
const minDegrees = (mins * 6) + 90;
88+
minHand.style.transform=`rotate(${minDegrees}deg)`;
89+
90+
const hours = now.getHours();
91+
const hourDegrees = (hours * 30) + 90;
92+
hourHand.style.transform=`rotate(${hourDegrees}deg)`;
93+
}
94+
setInterval(setDate, 1000);
7195

7296
</script>
7397
</body>

0 commit comments

Comments
 (0)