Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Analog Clock Using HTML CSS JS/clock.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Analog Clock Using HTML CSS JS/clock.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions Analog Clock Using HTML CSS JS/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#clockContainer{
/* border: 2px solid red; */
height: 42vw;
width: 42vw;
background: url('clock.jpg') no-repeat;
background-size: 100%;
margin: auto;
position: relative;
}

#hour, #minute, #second{
position: absolute;
/* background-color: black; */
border-radius: 10px;
transform-origin: bottom;
}
#hour{
opacity: 0.9;
width: 1.8%;
height: 25%;
top: 23%;
left: 48.48%;
background-color: #032639;
/* display: none; */
}
#minute{
width: 0.9%;
height: 31%;
top: 17%;
left: 49%;
opacity: 0.8;
background-color: rgb(63 4 4);
/* display: none; */
}
#second{
width: 0.6%;
height: 36%;
top: 12%;
left: 49.1%;
opacity: 0.7;
background-color: black;
/* display: none; */
}
19 changes: 19 additions & 0 deletions Analog Clock Using HTML CSS JS/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Clock Using Pure JS</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div id="clockContainer">
<div id="hour"></div>
<div id="minute"></div>
<div id="second"></div>
</div>

<script src="index.js"></script>
</body>
</html>
13 changes: 13 additions & 0 deletions Analog Clock Using HTML CSS JS/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
setInterval(() => {
d = new Date();
htime = d.getHours();
mtime = d.getMinutes();
stime = d.getSeconds();
hrotation = 30*htime + mtime/2;
mrotation = 6*mtime;
srotation = 6*stime;

hour.style.transform = `rotate(${hrotation}deg)`;
minute.style.transform = `rotate(${mrotation}deg)`;
second.style.transform = `rotate(${srotation}deg)`;
}, 1000);