Clock
<!DOCTYPE html>
<html>
<head>
<title>Clock Html</title>
</head>
<body>
<div class="clock">
<div class="hour">
<div class="hr" id="hr"></div>
</div>
<div class="min">
<div class="mn" id="mn"></div>
</div>
<div class="sec">
<div class="sc" id="sc"></div>
</div>
</div>
<script type="text/javascript">
const deg = 6;
const hr = document.querySelector("#hr");
const mn = document.querySelector("#mn");
const sc = document.querySelector("#sc");
setInterval(() => {
let day = new Date();
let hh = day.getHours() * 30;
let mm = day.getMinutes() * deg;
let ss = day.getSeconds() * deg;
hr.style.transform = `rotateZ(${hh+(mm/12)}deg)`;
mn.style.transform = `rotateZ(${mm}deg)`;
sc.style.transform = `rotateZ(${ss}deg)`;
})
</script>
</body>
</html>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #68a4ff;
}
.clock{
width: 250px;
height: 250px;
display: flex;
justify-content: center;
align-items: center;
background: #fff url(clock.png);
background-size: cover;
border-radius: 50%;
border: 20px solid #fff;
box-shadow: inset 0 0 30px rgba(0,0,0,.1),
0 20px 20px rgba(0, 0, 0, 0.2),
0 0px 0px 4px rgba(255, 255, 255, 1);
}
.clock::before{
content: '';
position: absolute;
width: 15px;
height: 15px;
background-color: #848484;
border:2px solid #fff;
z-index: 100000;
border-radius: 50%;
}
.hour,
.min,
.sec{
position: absolute;
}
.hour, .hr{
width: 160px;
height: 160px;
}
.min, .mn{
width: 190px;
height: 190px;
}
.sec, .sc{
width: 230px;
height: 230px;
}
.hr,.mn,.sc{
display: flex;
justify-content: center;
position: absolute;
border-radius: 50%;
}
.hr::before{
content: '';
position: absolute;
width: 8px;
height: 80px;
background-color: #848484;
z-index: 10;
border-radius: 6px 6px 0px 0px;
}
.mn::before{
content: '';
position: absolute;
width: 4px;
height: 90px;
background-color: #d6d6d6;
z-index: 11;
border-radius: 6px 6px 0px 0px;
}
.sc::before{
content: '';
position: absolute;
width: 2px;
height: 155px;
background-color: #ff6767;
z-index: 12;
border-radius: 6px 6px 0px 0px;
}
</style>
<html>
<head>
<title>Clock Html</title>
</head>
<body>
<div class="clock">
<div class="hour">
<div class="hr" id="hr"></div>
</div>
<div class="min">
<div class="mn" id="mn"></div>
</div>
<div class="sec">
<div class="sc" id="sc"></div>
</div>
</div>
<script type="text/javascript">
const deg = 6;
const hr = document.querySelector("#hr");
const mn = document.querySelector("#mn");
const sc = document.querySelector("#sc");
setInterval(() => {
let day = new Date();
let hh = day.getHours() * 30;
let mm = day.getMinutes() * deg;
let ss = day.getSeconds() * deg;
hr.style.transform = `rotateZ(${hh+(mm/12)}deg)`;
mn.style.transform = `rotateZ(${mm}deg)`;
sc.style.transform = `rotateZ(${ss}deg)`;
})
</script>
</body>
</html>
<style type="text/css">
*{
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #68a4ff;
}
.clock{
width: 250px;
height: 250px;
display: flex;
justify-content: center;
align-items: center;
background: #fff url(clock.png);
background-size: cover;
border-radius: 50%;
border: 20px solid #fff;
box-shadow: inset 0 0 30px rgba(0,0,0,.1),
0 20px 20px rgba(0, 0, 0, 0.2),
0 0px 0px 4px rgba(255, 255, 255, 1);
}
.clock::before{
content: '';
position: absolute;
width: 15px;
height: 15px;
background-color: #848484;
border:2px solid #fff;
z-index: 100000;
border-radius: 50%;
}
.hour,
.min,
.sec{
position: absolute;
}
.hour, .hr{
width: 160px;
height: 160px;
}
.min, .mn{
width: 190px;
height: 190px;
}
.sec, .sc{
width: 230px;
height: 230px;
}
.hr,.mn,.sc{
display: flex;
justify-content: center;
position: absolute;
border-radius: 50%;
}
.hr::before{
content: '';
position: absolute;
width: 8px;
height: 80px;
background-color: #848484;
z-index: 10;
border-radius: 6px 6px 0px 0px;
}
.mn::before{
content: '';
position: absolute;
width: 4px;
height: 90px;
background-color: #d6d6d6;
z-index: 11;
border-radius: 6px 6px 0px 0px;
}
.sc::before{
content: '';
position: absolute;
width: 2px;
height: 155px;
background-color: #ff6767;
z-index: 12;
border-radius: 6px 6px 0px 0px;
}
</style>
Comments
Post a Comment