The content on this website, including videos and code examples, is for educational purposes only. All demonstrations and designs are fictional and created to illustrate coding techniques. Any resemblance to existing websites or brands is purely coincidental.
The creators and administrators of this website do not claim ownership or affiliation with any existing websites or companies. Users are encouraged to use the information responsibly for learning purposes. Liability for any misuse of the content provided is not accepted.
Below is the html code for this video.
index.html
<!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>Glitch Clock</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="screen glitch">
<div class="clock is-off">
<span class="time" time-to-show="00: 00: 00">00: 00 : 00</span>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
Below is the css code for this video.
style.css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100vh;
width: 100%;
background: #020202;
color: #fdfefe;
font-weight: 700;
overflow: hidden;
}
.screen {
position: relative;
height: 100%;
width: 100%;
z-index: 1;
overflow: hidden;
}
.clock {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: block;
height: 128px;
width: 720px;
text-align: center;
margin: auto;
z-index: 9;
}
.clock span {
position: relative;
display: block;
font-size: 128px;
line-height: 1;
}
.clock.is-off {
animation: clockIsOffAnim 2s linear infinite;
}
@keyframes clockIsOffAnim {
0%, 50%, 58%, 80%, 85% {
opacity: 1;
}
56%, 57%, 81%, 84% {
opacity: 0;
}
71%, 73% {
transform: scaleY(1) skewX(0deg);
}
72% {
transform: scaleY(2) skewX(-45deg);
}
91%, 93% {
transform: scaleX(1) scaleY(1) skewX(0deg);
color: #fdfefe;
}
92% {
transform: scaleX(1.5) scaleY(0.25) skewX(75deg);
color: #0ffbf9;
}
}
.glitch::before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-image: linear-gradient(0, #fdfefe1a 10%, transparent 10%, transparent 50%, #fdfefe1a 50%, #fdfefe1a 60%, transparent 60%, transparent);
background-size: 100% 8px;
animation: bgMoveAnim 22s linear infinite;
z-index: 99;
}
@keyframes bgMoveAnim {
0% {
background-position: 0 0;
}
100% {
background-position: 0 -32px;
}
}
.glitch .clock {
transform: skewX(0deg) scaleY(1);
animation: clockBg 4s linear infinite;
}
@keyframes clockBg {
0% {
transform: translate(3px, 4px);
}
1%, 2% {
transform: scaleY(1) skewX(0deg);
}
1.5% {
transform: scaleY(2) skewX(-45deg);
}
10% {
transform: translate(2px, 4px);
}
20% {
transform: translate(2px, 3px);
}
30% {
transform: translate(3px, 2px);
}
40% {
transform: translate(1px, 4px);
}
50% {
transform: translate (2px, 1px);
}
51%, 53% {
transform: scaleX(1) scaleY(1) skewX(0);
}
52% {
transform: scaleX(1.5) scaleY(0.25) skewX(75deg);
}
60% {
transform: translate(3px, 1px);
}
70% {
transform: translate(5px, 4px);
}
80% {
transform: translate(1px, 3px);
}
90% {
transform: translate(5px, 3px);
}
100% {
transform: translate(5px, 2px);
}
}
.glitch .clock span::before, .glitch .clock span::after {
content: attr(time-to-show);
position: absolute;
top: 0;
display: block;
height: 128px;
width: 720px;
color: #fdfefe;
background: 0#020202;
clip: rect (0, 900px, 0, 0);
overflow: hidden;
}
.glitch .clock span::before {
left: -2px;
text-shadow: 2px 0 #537cbb;
animation: glitchBlueAnim 1s linear alternate-reverse infinite;
}
@keyframes glitchBlueAnim {
0% {
clip: rect(69px, 9999px, 63px, 0);
}
10% {
clip: rect(28px, 9999px, 12px, 0);
}
20% {
clip: rect(63px, 9999px, 74px, 0);
}
25% {
transform: scaleX(0.75);
}
30% {
clip: rect(65px, 9999px, 15px, 0);
}
40% {
clip: rect(37px, 9999px, 84px, 0);
}
50% {
clip: rect(27px, 9999px, 16px, 0);
}
60% {
clip: rect(95px, 9999px, 31px, 0);
}
70% {
clip: rect(23px, 9999px, 75px, 0);
}
80% {
clip: rect(3px, 9999px, 94px, 0);
}
90% {
clip: rect (67px, 9999px, 86px, 0);
}
100% {
clip: rect(35px, 9999px, 36px, 0);
}
}
.glitch .clock span::after {
left: 2px;
text-shadow: -2px 0 #cc0f39;
animation: glitchRedAnim 2s linear infinite;
}
@keyframes glitchRedAnim {
0% {
clip: rect(99px, 9999px, 5px, 0);
}
10% {
clip: rect(18px, 9999px, 22px, 0);
}
20% {
clip: rect(71px, 9999px, 25px, 0);
}
30% {
clip: rect(90px, 9999px, 100px, 0);
}
40% {
clip: rect(12px, 9999px, 34px, 0);
}
50% {
clip: rect(33px, 9999px, 25px, 0);
}
60% {
clip: rect(29px, 9999px, 89px, 0);
}
70% {
clip: rect(98px, 9999px, 50px, 0);
}
80% {
clip: rect(28px, 9999px, 80px, 0);
}
90% {
clip: rect(53px, 9999px, 92px, 0);
}
100% {
clip: rect(2px, 9999px, 39px, 0);
}
}
Below is the javascript code for this video.
index.js
document.addEventListener("DOMContentLoaded", function () {
setTimeout(function () { document.querySelector(".clock").classList.remove("is-off"); }, 2000);
setInterval(function () {
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
var timeToShow = (hours < 10 ? "0" : "") + hours + " : " + (minutes < 10 ? "0" : "") + minutes + " : " + (seconds < 10 ? "0" : "") + seconds;
document.querySelector(".time").innerHTML = timeToShow;
document.querySelector(".time").setAttribute("time-to-show", timeToShow);
}, 1000);
});
Thanks for visiting