Skip to content

Commit a0fa1d4

Browse files
Merge pull request #202 from Jothishwar/main
CSS clock
2 parents 32b358b + 2e9403c commit a0fa1d4

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

Css Animations/CSS clock/Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clock using CSS and Js
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
function setdate() {
3+
const d=new Date();
4+
const sec=d.getSeconds();
5+
const min=d.getMinutes();
6+
const hour=d.getHours();
7+
const secDeg=((sec/60)*360)+90;
8+
const minDeg=((min/60)*360)+((sec/60)*6)+90;
9+
const hrDeg=((hour/12)*360)+((min/60)*30)+90;
10+
document.querySelector('.second-hand').style.transform = `rotate(${secDeg}deg)`;
11+
document.querySelector('.min-hand').style.transform = `rotate(${minDeg}deg)`;
12+
document.querySelector('.hour-hand').style.transform = `rotate(${hrDeg}deg)`;
13+
//console.log(hour,min,sec);
14+
}
15+
setInterval(setdate,1000);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
html{
2+
background: #018DED url(https://unsplash.it/1500/1000?image=881&blur=5);
3+
background-repeat: no-repeat;
4+
background-size: cover;
5+
}
6+
.clock{
7+
height: 100vh;
8+
display: flex;
9+
justify-content: center;
10+
align-items: center;
11+
}
12+
.clock-face{
13+
width: 300px;
14+
height: 300px;
15+
border-radius: 50%;
16+
border: 15px solid floralwhite;
17+
position: relative;
18+
}
19+
.hand{
20+
width: 50%;
21+
height: 5px;
22+
background-color: black;
23+
top: 50%;
24+
position: absolute;
25+
transform-origin: 100%;
26+
transform: rotate(90deg);
27+
transition: all 0.05s;
28+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
29+
}
30+
.second-hand{
31+
width: 45%;
32+
left: 5%;
33+
height: 3px;
34+
}
35+
.min-hand{
36+
width: 30%;
37+
left: 20%;
38+
height: 4px;
39+
}
40+
.hour-hand{
41+
width: 25%;
42+
left: 25%;
43+
}

Css Animations/CSS clock/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>clock</title>
7+
<link rel="stylesheet" type="text/css" href="clock-stlye.css">
8+
<script type="text/javascript" src="clock-script.js"></script>
9+
</head>
10+
<body>
11+
<div class="clock">
12+
<div class="clock-face">
13+
<div class="hand hour-hand"></div>
14+
<div class="hand min-hand"></div>
15+
<div class="hand second-hand"></div>
16+
</div>
17+
</div>
18+
</body>
19+
</html>

0 commit comments

Comments
 (0)