Skip to content

50Projects-HTML-CSS-JavaScript : Analog watch #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 22, 2024
Merged
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ In order to run this project you need:
</details>
</li>

<li>
<details>
<summary>Analog Watch</summary>
<p>Analog Watch is a visually appealing and functional timekeeping tool built using HTML, CSS, and JavaScript. This project features a classic analog clock design with distinct hour, minute, and second hands. The clock displays the current time with real-time updates, and its stylish design includes subtle shadowing and color adjustments to enhance its aesthetic appeal. The clock’s hands are dynamically styled with CSS for a modern and engaging look.</p>
<ul>
<li><a href="https://tajulafreen.github.io/50Projects-HTML-CSS-JavaScript/Source-Code/AnalogWatch/">Live Demo</a></li>
<li><a href="https://github.com/tajulafreen/50Projects-HTML-CSS-JavaScript/tree/main/AnalogWatch/Calculator">Source</a></li>
</ul>
</details>
</li>

</ol>

<p align="right">(<a href="#readme-top">back to top</a>)</p>
Expand Down
Binary file added Source-Code/AnalogWatch/assets/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions Source-Code/AnalogWatch/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Analog Watch</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="clock">
<div class="hour" id="hour">
<div class="hr" id="hr"></div>
</div>
<div class="hand minute" id="minute">
<div class="mn" id="mn"></div>
</div>
<div class="hand second" id="second">
<div class="sc" id="sc"></div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions Source-Code/AnalogWatch/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
document.addEventListener('DOMContentLoaded', () => {
const hr = document.querySelector('#hr');
const mn = document.querySelector('#mn');
const sc = document.querySelector('#sc');

const deg = 6;

setInterval(() => {
const day = new Date();
const h = day.getHours() * 30;
const m = day.getMinutes() * deg;
const s = day.getSeconds() * deg;

hr.style.transform = `rotate(${h + m / 12}deg)`;
mn.style.transform = `rotate(${m}deg)`;
sc.style.transform = `rotate(${s}deg)`;
});
});
97 changes: 97 additions & 0 deletions Source-Code/AnalogWatch/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #2a083d;
z-index: -1;
}

.clock {
width: 350px;
height: 350px;
background: url("./assets/clock.png");
background-size: cover;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
border: 4px solid #091921;
box-shadow:
0 -15px 15px rgba(255, 255, 255, 0.25),
inset 0 -15px 15px rgba(255, 255, 255, 0.05),
0 15px 15px rgba(0, 0, 0, 0.3),
inset 0 15px 15px rgba(0, 0, 0, 0.3);
}

.clock::before {
content: "";
position: absolute;
width: 15px;
height: 15px;
background: #848484;
border: 2px solid #fff;
z-index: 10;
border-radius: 50%;
}

.hour,
.min,
.sec {
position: absolute;
}

.hour,
.hr {
width: 160px;
height: 160px;
}

.min,
.mn {
height: 190px;
}

.hr,
.mn,
.sc {
display: flex;
justify-content: center;
border-radius: 50%;
}

.hr::before {
content: "";
position: absolute;
width: 8px;
height: 80px;
background: #848484;
z-index: 1;
border-radius: 6px 6px 0 0;
}

.mn::before {
content: "";
position: absolute;
width: 4px;
height: 90px;
background: #d6d6d6;
z-index: 2;
border-radius: 6px 6px 0 0;
}

.sc::before {
content: "";
position: absolute;
width: 2px;
height: 150px;
background: #ff6767;
z-index: 3;
border-radius: 6px 6px 0 0;
}
Loading