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
38 changes: 38 additions & 0 deletions digitalclock/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!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>Document</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1><u>clock</u></h1>
<div class="clock">
<div>
<span id="hour">00 </span><span class="text">Hours</span>
</div>

<div>
<span id="minute"> 00 </span><span class="text">Minutes</span>
</div>

<div>
<span id="second">00 </span><span class="text">seconds</span>
</div>
<div>
<span id="ampm">AM</span>
</div>
</div>
<div class="dark">
<input type="checkbox" id="dark-mode" class="input">
<label for="dark-mode" class="label">
<div class="circle">

</div>
</label></div>
<script src="index.js"></script>
<script src="index1.js"></script>
</body>
</html>
29 changes: 29 additions & 0 deletions digitalclock/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const hourEl =document.getElementById("hour")
const minuteEl =document.getElementById("minute")
const secondEl =document.getElementById("second")
const ampmEl =document.getElementById("ampm")

function updateclock(){
let h = new Date().getHours()
let m = new Date().getMinutes()
let s =new Date().getSeconds()
let ampm = "AM";
if(h>12){
h=h-12
ampm = "PM";
}
h = h < 9 ? "0"+ h : h;
m = m < 9 ? "0"+ m : m ;
s = s < 9 ? "0"+ s : s ;


hourEl.innerText = h;
minuteEl.innerText = m
secondEl.innerText = s
ampmEl.innerText = ampm

setTimeout(()=>{
updateclock()
},1000)
}
updateclock()
125 changes: 125 additions & 0 deletions digitalclock/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
body {
margin: 0;
padding: 0;
position: relative;
display: flex;
flex-direction: column;
align-items: center;
height: 10svh;
justify-content: center;
background-color:wheat;
font-family: sans-serif;
}

h1 {
text-transform: uppercase;
color: white;
font-size: 25px;
letter-spacing: 0.5px;
text-align: center;
font-weight: 20;
margin: 0;

}

.clock {
display: flex;

}

.clock div {
margin: 5px;

}

.clock span {
width: 50px;
height: 40px;
opacity: 0.9;
color: rgb(75, 13, 247);
background:gray;
display: flex;
justify-content: center;
align-items: center;
font-size: 13px;
font-weight: bolder;
text-shadow: 2px 2px 4px rgb(243, 5, 164);
overflow: hidden;
}
.clock .text{
height: 15px;
font-size: 5px;
text-transform: uppercase;
letter-spacing: 1px;
background: aqua;
opacity: 0.8;
}
.clock #ampm{

width: 30px;
height: 15px;

text-emphasis-color: red;
font-size: 10px;

position: absolute;
}
.dark{
position: relative;
margin: 2%;
padding: 5px,2px,3px,2px;
display: flex;
justify-content: center;

transition: .4s;
}
.input{
visibility: hidden;
}
.label{
width: 40px;
height: 20;
background-color: lightgray;
border-radius: 20px;
cursor: pointer;

}
.circle{
width: 17px;
background-color:white;
height: 17px;
border-radius: 50%;
position: absolute;
left: 20px;
animation: toggleoff .2s
linear forwards;


}
.input:checked + .label{
background-color: salmon;
}
.input:checked + .label .circle{
animation: toggleon .2s
linear forwards;
background-color: black;
}

@keyframes toggleon{

0%{
transform: translateX(0);
}
100%{
transform: translateX(25px);
}
}
@keyframes toggleoff{

0%{
transform: translateX(25px);
}
100%{
transform: translateX(0);
}
}