Digital Clock Using HTML and CSS and JAVASCRIPT
This Is a Digital Clock Using HTML and CSS And JAVASCRIPT.
I fetched local time(GMT 5:30) using javascript function gethours and getminutes and getseconds
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Digital Clock Javascript</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="hero">
<div class="container">
<div class="clock">
<span id="hrs">00</span>
<span>:</span>
<span id="min">00</span>
<span>:</span>
<span id="sec">00</span>
</div>
</div>
</div>
<Script>
let hrs = document.getElementById("hrs");
let min = document.getElementById("min");
let sec = document.getElementById("sec");
setInterval(() => {
let currentTime = new Date();
hrs.innerHTML = (currentTime.getHours()<10?"0":"") + currentTime.getHours();
min.innerHTML = (currentTime.getMinutes()<10?"0":"") + currentTime.getMinutes();
sec.innerHTML = (currentTime.getSeconds()<10?"0":"") + currentTime.getSeconds();
}, 1000)
</Script>
</body>
</html>
CSS
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
box-sizing: border-box;
}
.hero {
width: 100%;
min-height: 100vh;
background: linear-gradient(45deg, #08001f, #30197d);
color: #fff;
position: relative;
}
.container {
width: 800px;
height: 180px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.clock {
width: 100%;
height: 100%;
background: rgba(235, 0, 255, 0.11);
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
backdrop-filter: blur(40px);
}
.container::before {
content: '';
width: 180px;
height: 180px;
background: #f41b75;
border-radius: 5px;
position: absolute;
left: -50px;
top: -50px;
z-index: -1;
}
.container::after {
content: '';
width: 180px;
height: 180px;
background: #419aff;
border-radius: 50%;
position: absolute;
right: -30px;
bottom: -50px;
z-index: -1;
}
.clock span {
font-size: 80px;
width: 110px;
display: inline-block;
text-align: center;
position: relative;
}
.clock span::after {
font-size: 16px;
position: absolute;
bottom: -5px;
left: 50%;
transform: translateX(-50%);
}
#hrs::after{
content: 'HOURS';
}
#min::after{
content: 'MINS';
}
#sec::after{
content: 'SEC';
}
Result-
https://debadatta77.github.io/Digitalclock/
(Open Desktop Site)
Comments
Post a Comment