Skip to content

Commit 7fe2b40

Browse files
committed
added new clock
1 parent 19c7388 commit 7fe2b40

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

Clock/thinkswell/back.jpg

188 KB
Loading

Clock/thinkswell/index.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
8+
<link rel="stylesheet" href="./style.css" />
9+
<title>Web Clock</title>
10+
</head>
11+
12+
<body>
13+
<div class="App">
14+
<div class="clock">
15+
<div class="hand sec"></div>
16+
<div class="hand min"></div>
17+
<div class="hand hrs"></div>
18+
</div>
19+
</div>
20+
</body>
21+
<script src="./sript.js"></script>
22+
23+
</html>

Clock/thinkswell/sript.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const secHand = document.querySelector(".sec");
2+
const minHand = document.querySelector(".min");
3+
const hrsHand = document.querySelector(".hrs");
4+
5+
function setTime() {
6+
const now = new Date();
7+
8+
const sec = now.getSeconds();
9+
const min = now.getMinutes();
10+
const hrs = now.getHours();
11+
12+
console.log(`${hrs} ${min} ${sec}`);
13+
14+
const secDegree = (sec / 60) * 360;
15+
const minDegree = (min / 60) * 360;
16+
const hrsDegree = (hrs / 12) * 360;
17+
18+
secHand.style.transform = `rotate(${secDegree + 90}deg)`;
19+
minHand.style.transform = `rotate(${minDegree}deg)`;
20+
hrsHand.style.transform = `rotate(${hrsDegree}deg)`;
21+
}
22+
setInterval(setTime, 1000);

Clock/thinkswell/style.css

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
* {
2+
margin: 0 auto;
3+
padding: 0;
4+
}
5+
6+
html {
7+
font-size: 62.5%;
8+
box-sizing: border-box;
9+
}
10+
11+
body {
12+
box-sizing: inherit;
13+
}
14+
15+
.App {
16+
width: 100%;
17+
min-height: 100vh;
18+
background: url("back.jpg");
19+
background-size: cover;
20+
background-position: center;
21+
display: flex;
22+
justify-content: center;
23+
align-items: center;
24+
flex-wrap: wrap;
25+
}
26+
27+
.clock {
28+
width: 20rem;
29+
height: 20rem;
30+
border-radius: 50%;
31+
border: 2rem solid rgb(255, 177, 8);
32+
position: relative;
33+
transform: rotate(90deg);
34+
}
35+
36+
.hand {
37+
position: absolute;
38+
width: 50%;
39+
height: 1rem;
40+
background: rgb(255, 177, 8);
41+
top: 50%;
42+
transform-origin: 100%;
43+
clip-path: polygon(10% 0, 100% 0, 100% 100%, 10% 100%, 0 50%);
44+
transition: all 0.05s;
45+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1.2);
46+
border-radius: 0 1rem 1rem 0;
47+
}

0 commit comments

Comments
 (0)