Skip to content

I add a digital clock project #21

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -113,6 +113,11 @@ This repository contains a collection of frontend projects.Each project is built
<td>Bubble Game</td>
<td><a href="./project-20_bubble_game">Click Here</a></td>
</tr>
<tr>
<td>21</td>
<td>digital clock</td>
<td><a href="./project-21_digital_clock">Click Here</a></td>
</tr>
</table>


4 changes: 2 additions & 2 deletions project-1_landing-page/css/index.css
Original file line number Diff line number Diff line change
@@ -249,7 +249,7 @@ header .navbar .menu-items li a {
}

#contact {
margin: auto;
margin:auto;
width: 100%;
height: max-content;
display: flex;
@@ -453,7 +453,7 @@ footer .socials li .bi-linkedin {
padding: 10px;
}
#contact form {
width: 350px;
width: 320px;
}
footer {
padding: 0;
84 changes: 84 additions & 0 deletions project-21_digital_clock/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
html,body{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.hero{
margin: 0;
padding: 0;
width:100%;
min-height:100vh;
background: linear-gradient(45deg,#08001f,#30197d);
position: relative;
color: #fff;
}
.container{
width:200px;
height: 80px;
position: absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
.clock{
width:100%;
height: 100%;
background: rgba(135,0,245,0.11);
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
backdrop-filter: blur(15px);
}
.container::before{
content:"";
width:90px;
height: 90px;
background: #f0f0f0;
border-radius: 5px;
position: absolute;
top:-50px;
left:-50px;
z-index:-1;
/* box-shadow: 5px 5px 10px rgb(255,255,255,0.5); */
}
.container::after{
content:"";
width:90px;
height: 90px;
background: #0f0f0f;
border-radius: 50%;
position: absolute;
right:-30px;
bottom:-50px;
z-index:-1;
/* box-shadow: 5px 5px 10px rgba(0,0,0,0.5); */
}
.clock span{
font-size: 35px;
width: 35px;
display: inline-block;
text-align: center;
position: relative;
}
.clock span::after{
font-size: 6px;
position: absolute;
bottom: -5px;
left: 50%;
transform: translateX(-50%);
}
.clock #hours::after{
content:"HOUR";
}
#minutes::after{
content: "MINUTE";
}
#seconds::after{
content: "SECOND";
}
@media (min-width:1068px){
.hero{
transform: scale(1.3);
}
}
24 changes: 24 additions & 0 deletions project-21_digital_clock/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="./css/styles.css" type="text/css" media="all" />
</head>
<body>
<section class="hero">
<div class="container">
<div class="clock">
<span id="hours"></span>
<span>:</span>
<span id="minutes"></span>
<span>:</span>
<span id="seconds"></span>
</div>
</div>
</section>
<script src="./js/script.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions project-21_digital_clock/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const hour = document.querySelector("#hours")
const minute = document.querySelector("#minutes")
const second = document.querySelector("#seconds")
function handelar() {
const currentTime = new Date();
const hrs = currentTime.getHours();
const mins = currentTime.getMinutes();
const secs = currentTime.getSeconds();
if(hrs < 10){
hour.innerHTML = "0" + hrs;
}else{
hour.innerHTML = "" + hrs;
}
if(mins < 10){
minute.innerHTML = "0" + mins;
}else{
minute.innerHTML = mins;
}
if(secs < 10){
second.innerHTML = "0" + secs;
}else{
second.innerHTML = secs;
}
}
setTimeout(handelar,1);
setInterval(handelar, 1000);