-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
51 lines (44 loc) · 1.23 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="output.css">
<title>Clockwork</title>
</head>
<body>
<div class="clock">
<div class="clockface">
<div class="hand hour"></div>
<div class="hand minute"></div>
<div class="hand second"></div>
</div>
</div>
<script>
var minute = document.getElementsByClassName('minute')[0];
var second = document.getElementsByClassName('second')[0];
var hour = document.getElementsByClassName('hour')[0];
function setDate (){
var now = new Date(),
seconds = now.getSeconds(),
minutes = now.getMinutes(),
hours = now.getHours();
var secondDegrees = seconds*6 + 90;
var minuteDegrees = minutes*6 + 90;
var hourDegrees = hours*30 + 90;
second.style.transform = `rotate(${secondDegrees}deg)`;
minute.style.transform = `rotate(${minuteDegrees}deg)`;
hour.style.transform = `rotate(${hourDegrees}deg)`;
}
setInterval(setDate,1000);
// var date = new Date();
// var nowHour = date.getHours();
// var nowMinute = date.getMinutes();
// var nowSecond = date.getSeconds();
// setInterval(function clock(time,now){
// time.style['transform'] = 'rotate' + '(' + ${90 + now*6} + 'deg' + ')';
// },1000);
//
// clock(second,nowSecond);
</script>
</body>
</html>