Skip to content

Commit 96257d9

Browse files
committed
Rename directory to show complete
1 parent 4b7b160 commit 96257d9

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>JS + CSS Clock</title>
6+
<link rel="stylesheet" href="style.css" media="screen" title="no title">
7+
</head>
8+
<body>
9+
<div class="clock">
10+
<div class="clock-face">
11+
<div class="hand hour-hand"></div>
12+
<div class="hand min-hand"></div>
13+
<div class="hand second-hand"></div>
14+
</div>
15+
</div>
16+
<script type="text/javascript" src="main.js"></script>
17+
</body>
18+
</html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var secondHand = document.querySelector('.second-hand')
2+
var minHand = document.querySelector('.min-hand')
3+
var hourHand = document.querySelector('.hour-hand')
4+
5+
function setDate () {
6+
var now = new Date()
7+
var seconds = now.getSeconds()
8+
var secondsDegrees = ((seconds / 60) * 360) + 90
9+
// could apply below to secs, mins, hours to avoid '90deg glitch'
10+
if (secondsDegrees === 90) {
11+
secondHand.className = 'hand second-hand no-transition'
12+
} else if (secondsDegrees === 96) {
13+
secondHand.className = 'hand second-hand'
14+
}
15+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`
16+
17+
var mins = now.getMinutes()
18+
var minsDegrees = ((mins / 60) * 360) + 90
19+
minHand.style.transform = `rotate(${minsDegrees}deg)`
20+
21+
var hours = now.getHours()
22+
var hoursDegrees = ((hours / 12) * 360) + 90
23+
hourHand.style.transform = `rotate(${hoursDegrees}deg)`
24+
}
25+
26+
setInterval(setDate, 1000)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
html {
2+
background:#018DED url(http://unsplash.it/1500/1000?image=881&blur=50);
3+
background-size:cover;
4+
font-family:'helvetica neue';
5+
text-align: center;
6+
font-size: 10px;
7+
}
8+
9+
body {
10+
font-size: 2rem;
11+
display:flex;
12+
flex:1;
13+
min-height: 100vh;
14+
align-items: center;
15+
}
16+
17+
.clock {
18+
width: 30rem;
19+
height: 30rem;
20+
border:20px solid white;
21+
border-radius:50%;
22+
margin:50px auto;
23+
position: relative;
24+
padding:2rem;
25+
box-shadow:
26+
0 0 0 4px rgba(0,0,0,0.1),
27+
inset 0 0 0 3px #EFEFEF,
28+
inset 0 0 10px black,
29+
0 0 10px rgba(0,0,0,0.2);
30+
}
31+
32+
.clock-face {
33+
position: relative;
34+
width: 100%;
35+
height: 100%;
36+
transform: translateY(-3px); /* account for the height of the clock hands */
37+
}
38+
39+
.hand {
40+
width:50%;
41+
height:6px;
42+
background:black;
43+
position: absolute;
44+
top:50%;
45+
transform-origin: 100%;
46+
transform: rotate(90deg);
47+
transition: all 0.05s;
48+
transition-timing-function: cubic-bezier(0.57, 2.01, 0.18, 0.88);
49+
}
50+
51+
.no-transition {
52+
transition: none;
53+
}

0 commit comments

Comments
 (0)