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

Skip to content

Commit e2c623f

Browse files
author
emodo
committed
Distinguish between hour and minute hands
1 parent 94f9659 commit e2c623f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,18 @@
5353
position: relative;
5454
width: 100%;
5555
height: 100%;
56-
transform: translateY(-3px); /* account for the height of the clock hands */
56+
transform: translate(-3px, -3px); /* account for the height of the clock hands */
5757
}
5858

5959
.hand {
6060
width:50%;
6161
height:6px;
6262
background:black;
6363
position: absolute;
64-
top:50%;
65-
transform-origin: 100%;
66-
transform: rotate(90deg);
64+
top: 50%;
65+
left: 50%;
66+
transform-origin: 0%;
67+
transform: rotate(-90deg);
6768
transition: all 0.05s;
6869
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
6970
}
@@ -78,15 +79,15 @@
7879
const now = new Date();
7980

8081
const seconds = now.getSeconds();
81-
const secondsDegrees = ((seconds / 60) * 360) + 90;
82+
const secondsDegrees = ((seconds / 60) * 360) - 90;
8283
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
8384

8485
const mins = now.getMinutes();
85-
const minsDegrees = ((mins / 60) * 360) + ((seconds/60)*6) + 90;
86+
const minsDegrees = ((mins / 60) * 360) + ((seconds/60)*6) - 90;
8687
minsHand.style.transform = `rotate(${minsDegrees}deg)`;
8788

8889
const hour = now.getHours();
89-
const hourDegrees = ((hour / 12) * 360) + ((mins/60)*30) + 90;
90+
const hourDegrees = ((hour / 12) * 360) + ((mins/60)*30) - 90;
9091
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
9192
}
9293

0 commit comments

Comments
 (0)