荒廢了好多天,想要重振旗鼓,看到WesBos最近發佈了一堂免費的js課:
javascript30.com ,來挑戰看看吧!
時間安排如下:
CSS + JS clock
const secondHand = document.querySelector('.second-hand');
const minHand = document.querySelector('.min-hand');
const hourHand = document.querySelector('.hour-hand');
function setDate() {
const now = new Date();
const seconds = now.getSeconds();
const mins = now.getMinutes();
const hours = now.getHours();
const secondsDegrees = ((seconds/ 60) * 360)+ 90;
const minutesDegrees = ((mins/ 60) * 360)+ 90;
const hoursDegrees = ((hours/ 24) * 360)+ 90;
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
minHand.style.transform = `rotate(${minutesDegrees}deg)`;
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
}
setInterval(setDate, 1000);
真的要動手做喔
ps 逛一逛發現原來也有另外一個鐵有再分享這個課程,好巧。
大家都加油了,雖然我挑戰失敗了哈哈哈,但我會努力把30天完成