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 Diwali</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="text-container">
<h1 class="reveal-title">Happy Diwali</h1>
<p>
<span>With gleam of auspicious diyas and the holy chants,</span>
<span>may happiness and prosperity fill your life forever!</span>
</p>
</div>
<div class="container">
<div class="shadow"></div>
<div class="diya">
<div class="line1"></div>
<div class="line2"></div>
<div class="dots"></div>
</div>
<div class="light-flare">
<div class="light"></div>
<div class="flame"></div>
</div>
</div>
<canvas id="firework-bg"></canvas>
<script src="index.js"></script>
</body>
</html>
Below is the css code for this video.
style.css
*, *::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100vh;
background-color: #ffffff;
background-image: linear-gradient(#ff000080, #ffa50080);
}
.text-container {
position: absolute;
color: #ffffff;
margin: 1.25% 25% 0;
width: 50%;
text-align: center;
}
.reveal-title, .reveal-title::after {
animation-delay: 1s;
animation-iteration-count: 1;
animation-duration: 800ms;
animation-fill-mode: both;
animation-timing-function: cubic-bezier(0.0, 0.0, 0.25, 1);
}
.reveal-title {
position: relative;
font-family: cursive;
font-size: 54px;
padding: 1.25% 0 2.5%;
white-space: nowrap;
animation-name: revealTitle;
}
.reveal-title::after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #fdf1c2;
transform: scaleX(0);
transform-origin: 0 50%;
z-index: 2;
animation-name: titleOverlay;
pointer-events: none;
}
@keyframes revealTitle {
from {
clip-path: inset(0 100% 0 0);
}
to {
clip-path: inset(0 0 0 0);
}
}
@keyframes titleOverlay {
0%, 50% {
transform-origin: 0 50%;
}
60% {
transform: scaleX(1);
transform-origin: 100% 50%;
}
100% {
transform: scaleX(0);
transform-origin: 100% 50%;
}
}
p {
font-family: 'Courier New', Courier, monospace;
font-size: 18px;
line-height: 2;
}
p span {
display: block;
opacity: 0;
animation: showMe 2s forwards 2.5s;
}
.container {
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
height: 500px;
width: 500px;
opacity: 0;
animation: showMe 2s forwards 5s;
}
@keyframes showMe {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.shadow {
position: absolute;
left: 0;
bottom: 30px;
right: 0;
height: 60px;
width: 320px;
background-color: #80808040;
border-radius: 50%;
margin: auto;
}
.diya {
position: absolute;
left: 0;
bottom: 50px;
right: 0;
height: 150px;
width: 300px;
background-color: #fdcf0f;
border-radius: 0 0 150px 150px;
margin: auto;
overflow: hidden;
}
.line1, .line2 {
position: absolute;
left: -10px;
height: 60px;
width: 320px;
border: none;
border-bottom: 8px solid #ffffff;
border-radius: 50%;
}
.line2 {
top: 60px;
}
.dots {
position: absolute;
top: 30px;
left: -10px;
height: 60px;
width: 320px;
border: none;
border-bottom: 10px dotted #fd500a;
border-radius: 50%;
}
.light-flare {
position: absolute;
left: 0;
bottom: 170px;
right: 0;
height: 60px;
width: 300px;
background-color: #fd500a;
border-radius: 50%;
margin: auto;
}
.light {
position: absolute;
left: -15px;
bottom: 0;
height: 330px;
width: 330px;
background-color: #fff34f40;
border-radius: 50%;
}
.light::before, .light::after {
content: "";
position: absolute;
height: 120px;
width: 120px;
background-color: #fff34f80;
border-radius: 50%;
animation: shiningLight 4s linear infinite;
}
.light::before {
bottom: 30px;
right: 60px;
}
.light::after {
top: 50px;
left: 80px;
animation-delay: 1s;
}
@keyframes shiningLight {
50% {
transform: scale(0.75);
opacity: 0.25;
}
}
.flame {
position: absolute;
left: 0;
bottom: 36px;
right: 0;
transform: rotate(-45deg);
height: 170px;
width: 170px;
background-color: #fdf1c2;
border-radius: 160px 0;
margin: auto;
animation: burningFlame 4s infinite;
}
.flame::after {
content: "";
position: absolute;
bottom: 0;
height: 120px;
width: 120px;
background-color: #ffbd2e80;
border-radius: 120px 0;
}
@keyframes burningFlame {
50% {
bottom: 42px;
transform: rotate(-45deg) scale(1.1);
}
}
Below is the javascript code for this video.
index.js
window.addEventListener("resize", resizeCanvas, false);
window.addEventListener("DOMContentLoaded", onLoad, false);
window.requestAnimationFrame = window.requestAnimationFrame || function (callback) { window.setTimeout(callback, 1000 / 60); };
var canvas, ctx, w, h, particles = [], probability = 0.05, xPoint, yPoint;
function resizeCanvas() {
window.scrollTo(0, 0);
if (!!canvas) {
canvas.width = window.innerWidth;
w = window.innerWidth;
canvas.height = window.innerHeight;
h = window.innerHeight;
}
}
function onLoad() {
window.scrollTo(0, 0);
canvas = document.getElementById("firework-bg");
ctx = canvas.getContext("2d");
resizeCanvas();
setTimeout(() => window.requestAnimationFrame(updateBg), 7500);
}
function updateBg() {
window.scrollTo(0, 0);
update();
fireInSky();
window.requestAnimationFrame(updateBg);
}
function update() {
if (particles.length < 500 && Math.random() < probability) {
createFirework();
}
var alive = [];
for (var i = 0; i < particles.length; i++) {
if (particles[i].move()) {
alive.push(particles[i]);
}
}
particles = alive;
}
function fireInSky() {
ctx.globalCompositeOperation = "source-over";
ctx.fillStyle = `rgba( ${Math.random() * 33}, ${Math.random() * 33}, ${Math.random() * 33}, 0.25)`;
ctx.fillRect(0, 0, w, h);
ctx.globalCompositeOperation = "lighter";
for (var i = 0; i < particles.length; i++) {
particles[i].draw(ctx);
}
}
function createFirework() {
xPoint = Math.random() * (w - 200) + 100;
yPoint = Math.random() * (h - 200) + 100;
var nFire = Math.random() * 50 + 100;
var c = `rgb( ${Math.random() * 200 + 55}, ${Math.random() * 200 + 55}, ${Math.random() * 200 + 55})`;
for (var i = 0; i < nFire; i++) {
var particle = new Particle();
particle.color = c;
var vy = Math.sqrt(25 - particle.vx * particle.vx);
if (Math.abs(particle.vy) > vy) {
particle.vy = particle.vy > 0 ? vy : -vy;
}
particles.push(particle);
}
}
function Particle() {
this.w = this.h = Math.random() * 4 + 1;
this.x = xPoint - this.w / 2;
this.y = yPoint - this.h / 2;
this.vx = (Math.random() - 0.5) * 10;
this.vy = (Math.random() - 0.5) * 10;
this.alpha = Math.random() * 0.5 + 0.5;
this.color;
}
Particle.prototype = {
gravity: 0.05,
move: function () {
this.x += this.vx;
this.vy += this.gravity;
this.y += this.vy;
this.alpha -= 0.01;
if (this.x <= -this.w || this.x >= screen.width || this.y >= screen.height || this.alpha <= 0) {
return false;
}
return true;
},
draw: function (c) {
c.save();
c.beginPath();
c.translate(this.x + (this.w / 2), this.y + (this.h / 2));
c.arc(0, 0, this.w, 0, Math.PI * 2);
c.fillStyle = this.color;
c.globalAlpha = this.alpha;
c.closePath();
c.fill();
c.restore();
}
};
Thanks for visiting