Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion 02 - JS and CSS Clock/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,41 @@
background:black;
position: absolute;
top:50%;
transform-origin: 100%;
transform: rotate(90deg);
transition: all 0.5s;
}

</style>
.hour-hand {
background: red;
}

</style>

<script>

const secondHand = document.querySelector('.second-hand');
const minuteHand = document.querySelector('.min-hand');
const hourHand = document.querySelector('hour-hand');

function setDate() {
const now = new Date();

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

const minutes = now.getMinutes();
const minutesDegrees = ((minutes / 60) * 360) + 90;
minuteHand.style.transform = `rotate(${minutesDegrees}deg)`;

const hours = now.getHours();
const hoursDegrees = ((hours / 12) * 360) + 90;
hourHand.style.transform = `rotate(${hoursDegrees}deg`;

}

setInterval(setDate, 1000);

</script>
</body>
Expand Down