Skip to content

Commit a999ed9

Browse files
committed
new clock
1 parent b77e5f6 commit a999ed9

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed
1.26 MB
Loading

2MYCSSClock/index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>My Clock</title>
6+
<link rel="stylesheet" href="style.css">
7+
</head>
8+
<body>
9+
10+
<div class="clock-border">
11+
<div class="clock-face">
12+
<div class="hand sec"></div>
13+
<div class="hand min"></div>
14+
<div class="hand hr"></div>
15+
</div>
16+
</div>
17+
18+
<script src="index.js" charset="utf-8"></script>
19+
</body>
20+
</html>

2MYCSSClock/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const secondHand = document.querySelector(".sec")
2+
const minuteHand = document.querySelector(".min")
3+
const hourHand = document.querySelector(".hr")
4+
function setDate () {
5+
const now = new Date()
6+
, secs = now.getSeconds()
7+
, mins = now.getMinutes()
8+
, hrs = now.getHours()
9+
, secondsDegrees = ((secs / 60) * 360)+90
10+
, minutesDegrees = ((mins / 60) * 360)+90
11+
, hoursDegrees = ((hrs / 12) * 360)+90
12+
13+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`
14+
minuteHand.style.transform = `rotate(${minutesDegrees}deg)`
15+
hourHand.style.transform = `rotate(${hoursDegrees}deg)`
16+
}
17+
18+
setInterval(setDate, 1000)

2MYCSSClock/style.css

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
body {
2+
background-image: url("6b9y2vdjy_k-francesco-gallarotti.jpg");
3+
background-position: center;
4+
background-repeat: no-repeat;
5+
background-size: cover;
6+
background-attachment: fixed;
7+
display: flex;
8+
justify-content: center;
9+
text-align: center;
10+
top: 50%;
11+
}
12+
.clock-border{
13+
top: 5vh;
14+
width: 70vh;
15+
height: 70vh;
16+
border-radius: 50%;
17+
background-color: transparent;
18+
border: 25px white solid;
19+
position: relative;
20+
padding:2rem;
21+
box-shadow:
22+
0 0 0 4px rgba(0,0,0,0.1),
23+
inset 0 0 0 3px #EFEFEF,
24+
inset 0 0 10px black,
25+
0 0 10px rgba(0,0,0,0.2);
26+
}
27+
.clock-face {
28+
border-radius: 35vh;
29+
background-color: transparent;
30+
position: relative;
31+
width: 100%;
32+
height: 100%;
33+
transform: translateY(-3px); /* account for the height of the clock hands */
34+
}
35+
.hr {
36+
background-color: honeydew;
37+
}
38+
.min {
39+
background-color: maroon;
40+
}
41+
.sec {
42+
background-color: slategrey;
43+
}
44+
.hand{
45+
width:50%;
46+
height:6px;
47+
position: absolute;
48+
top:50%;
49+
transform-origin: 100%;
50+
transform: rotate(90deg);
51+
transition: all 0.05s;
52+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
53+
border-radius: 50%
54+
}

0 commit comments

Comments
 (0)