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>Happy New Year</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="loading">
<h2>2022</h2>
<div class="loading-bar"></div>
<h2>2023</h2>
</div>
<div class="ribbon">
<div>
<h2>Happy New Year</h2>
</div>
<div></div>
<div>
<h2>2023</h2>
</div>
<div></div>
</div>
<script src="index.js"></script>
</body>
</html>
Below is the css code for this video.
style.css
@import url('https://fonts.googleapis.com/css2?family=Parisienne&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
height: 100vh;
width: 100%;
background-color: #eec0c6;
background-image: radial-gradient(#eec0c6, #e58c8a);
font-family: 'Parisienne', cursive;
justify-content: center;
align-items: center;
overflow: hidden;
}
.loading {
position: fixed;
top: 0;
left: 0;
display: flex;
height: 100%;
width: 100%;
background: radial-gradient(#eec0c6, #e58c8a);
justify-content: center;
align-items: center;
animation: loadingFadeOutAnim 5.5s linear forwards;
z-index: 10;
}
@keyframes loadingFadeOutAnim {
0%, 90% {
opacity: 1;
visibility: visible;
}
100% {
opacity: 0;
visibility: hidden;
}
}
.loading .loading-bar {
position: relative;
height: 40px;
width: 400px;
background: transparent;
border: 2px solid #000000;
margin: 0 20px;
}
.loading .loading-bar::after {
content: "Loading...";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
color: #ffffff;
font-family: 'Courier New', Courier, monospace;
font-size: 20px;
text-align: center;
font-weight: bold;
line-height: 36px;
text-transform: uppercase;
letter-spacing: 10px;
mix-blend-mode: difference;
}
.loading .loading-bar::before {
content: "";
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: #000000;
transform-origin: left;
animation: unfoldAnim 5s linear forwards;
}
.ribbon {
position: relative;
width: 400px;
}
.ribbon div {
position: relative;
display: flex;
height: 100px;
justify-content: center;
align-items: center;
transform: skewY(-5deg);
margin: -30px 0;
z-index: 2;
}
.ribbon div:nth-child(2), .ribbon div:nth-child(4) {
transform: skewY(14.5deg);
z-index: 1;
}
.ribbon div:nth-child(4) {
top: -52px;
transform: skewY(25deg);
transform-origin: left;
}
.ribbon div::before {
content: "";
position: absolute;
height: 100%;
width: 100%;
}
.ribbon div:nth-child(1)::before, .ribbon div:nth-child(3)::before {
background: linear-gradient(-160deg, #37d5d6, #36096d);
transform: scaleX(0);
}
.ribbon div:nth-child(2)::before, .ribbon div:nth-child(4)::before {
background: linear-gradient(-20deg, #37d5d6, #36096d);
transform: scaleX(0);
}
.ribbon div:nth-child(1)::before {
transform-origin: right;
animation: unfoldAnim 1s linear forwards;
animation-delay: 6s;
backface-visibility: hidden;
}
.ribbon div:nth-child(2)::before {
transform-origin: left;
animation: unfoldAnim 1s linear forwards;
animation-delay: 7s;
backface-visibility: hidden;
}
.ribbon div:nth-child(3)::before {
transform-origin: right;
animation: unfoldAnim 1s linear forwards;
animation-delay: 8s;
backface-visibility: hidden;
}
.ribbon div:nth-child(4)::before {
left: 0;
width: 66.67%;
transform-origin: left;
animation: unfoldAnim 1s linear forwards;
animation-delay: 9s;
backface-visibility: hidden;
}
.ribbon div:nth-child(1)::after, .ribbon div:nth-child(3)::after {
content: "";
position: absolute;
left: 0;
bottom: 0;
height: 50%;
width: 100%;
}
.ribbon div h2 {
position: relative;
color: #ffffff;
z-index: 7;
opacity: 0;
}
.ribbon div:nth-child(1) h2 {
font-size: 48px;
animation: textFadeInAnim 0.5s linear forwards;
animation-delay: 6.75s;
}
.ribbon div:nth-child(3) h2 {
font-size: 84px;
animation: textFadeInAnim 0.5s linear forwards;
animation-delay: 8.75s;
}
@keyframes unfoldAnim {
0% {
transform: scaleX(0);
}
100% {
transform: scaleX(1);
}
}
@keyframes textFadeInAnim {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
canvas {
position: absolute;
height: 100%;
width: 100%;
}
Below is the javascript code for this video.
index.js
class Snow {
constructor() {
this.canvas = document.createElement("canvas");
this.ctx = this.canvas.getContext("2d");
document.body.appendChild(this.canvas);
window.addEventListener("resize", () => this.onResize());
this.onResize();
this.updateBound = this.update.bind(this);
requestAnimationFrame(this.updateBound);
this.createSnowflakes();
}
onResize() {
this.width = window.innerWidth;
this.height = window.innerHeight;
this.canvas.width = this.width;
this.canvas.height = this.height;
}
createSnowflakes() {
const flakes = window.innerWidth / 4;
this.snowflakes = [];
for (let i = 0; i < flakes; i++) { this.snowflakes.push(new SnowFlake()); }
}
update() {
this.ctx.clearRect(0, 0, this.width, this.height);
for (let flake of this.snowflakes) {
flake.update();
this.ctx.save();
this.ctx.fillStyle = "#ffffff";
this.ctx.beginPath();
this.ctx.arc(flake.x, flake.y, flake.radius, 0, Math.PI * 2);
this.ctx.closePath();
this.ctx.globalAlpha = flake.alpha;
this.ctx.fill();
this.ctx.restore();
}
requestAnimationFrame(this.updateBound);
}
}
class SnowFlake {
constructor() {
this.x = 0;
this.y = 0;
this.vx = 0;
this.vy = 0;
this.radius = 0;
this.alpha = 0;
this.reset();
}
reset() {
this.x = this.randomBetween(0, window.innerWidth);
this.y = this.randomBetween(0, -window.innerHeight);
this.vx = this.randomBetween(-3, 3);
this.vy = this.randomBetween(2, 5);
this.radius = this.randomBetween(1, 4);
this.alpha = this.randomBetween(0.1, 0.9);
}
randomBetween(min, max) { return min + Math.random() * (max - min); }
update() {
this.x += this.vx;
this.y += this.vy;
if (this.y + this.radius > window.innerHeight) { this.reset(); }
}
}
new Snow();
Thanks for visiting