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 name="viewport" content="width=device-width, initial-scale=1.0">
<title>Floral Tribute to Flag</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Happy Ind<span>epen</span>dence Day</h1>
<div class="flag">
<div class="mask">
<ul class="floral-popping">
<li class="flower-petal"></li>
<li class="flower-petal"></li>
<li class="flower-petal"></li>
<li class="flower-petal"></li>
<li class="flower-petal"></li>
<li class="flower-petal"></li>
</ul>
</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 {
display: flex;
height: 100vh;
width: 100%;
justify-content: center;
align-items: center;
overflow: hidden;
}
h1 {
position: relative;
color: #ffffff;
font-size: 60px;
font-family: cursive;
z-index: 3;
text-align: center;
text-shadow: 0 -4px #ff9933, -2px -2px #ff9933, 2px 2px #138808, 0 4px #138808;
}
h1 span {
color: #000080;
}
.flag {
position: absolute;
top: 0;
left: 0;
height: 100vh;
width: 100%;
background: radial-gradient(#000080 0%, transparent 25%, transparent 100%), linear-gradient(to bottom,
#ff9933 0%, #ff9933 33.32%, #ffffff 33.34%, #ffffff 66.66%, #138808 66.68%, #138808 100%);
}
.mask {
position: absolute;
top: 0;
left: 0;
height: 100vh;
width: 100%;
background: #808080f2;
mix-blend-mode: screen;
z-index: 2;
}
.floral-popping {
position: absolute;
top: 100vh;
left: 50%;
height: 5vmin;
width: 5vmin;
background: #000000;
border-radius: 50%;
list-style: none;
z-index: 2;
animation: floralPopping 3s infinite;
}
@keyframes floralPopping {
0% {
transform: translate(0%, 0%);
}
60% {
transform: translate(0%, -1300%) scale(1);
background: #ffffff;
}
63%, 100% {
transform: translate(0%, -1300%) scale(2);
background: #00000000;
}
}
.flower-petal {
position: absolute;
height: 100%;
width: 100%;
background: #ffffff;
border-radius: 24px;
}
.flower-petal:nth-child(1) {
animation: flowerPetal1 3s infinite;
}
@keyframes flowerPetal1 {
0%, 59% {
opacity: 0;
}
60% {
transform: rotate(60deg) translate(0%, 0%) scale(1, 1);
opacity: 1;
}
100% {
transform: rotate(60deg) translate(0%, -100%) scale(1, 5);
opacity: 0;
}
}
.flower-petal:nth-child(2) {
animation: flowerPetal2 3s infinite;
}
@keyframes flowerPetal2 {
0%, 59% {
opacity: 0;
}
60% {
transform: rotate(120deg) translate(0%, 0%) scale(1, 1);
opacity: 1;
}
100% {
transform: rotate(120deg) translate(0%, -100%) scale(1, 5);
opacity: 0;
}
}
.flower-petal:nth-child(3) {
animation: flowerPetal3 3s infinite;
}
@keyframes flowerPetal3 {
0%, 59% {
opacity: 0;
}
60% {
transform: rotate(180deg) translate(0%, 0%) scale(1, 1);
opacity: 1;
}
100% {
transform: rotate(180deg) translate(0%, -100%) scale(1, 5);
opacity: 0;
}
}
.flower-petal:nth-child(4) {
animation: flowerPetal4 3s infinite;
}
@keyframes flowerPetal4 {
0%, 59% {
opacity: 0;
}
60% {
transform: rotate(240deg) translate(0%, 0%) scale(1, 1);
opacity: 1;
}
100% {
transform: rotate(240deg) translate(0%, -100%) scale(1, 5);
opacity: 0;
}
}
.flower-petal:nth-child(5) {
animation: flowerPetal5 3s infinite;
}
@keyframes flowerPetal5 {
0%, 59% {
opacity: 0;
}
60% {
transform: rotate(300deg) translate(0%, 0%) scale(1, 1);
opacity: 1;
}
100% {
transform: rotate(300deg) translate(0%, -100%) scale(1, 5);
opacity: 0;
}
}
.flower-petal:nth-child(6) {
animation: flowerPetal6 3s infinite;
}
@keyframes flowerPetal6 {
0%, 59% {
opacity: 0;
}
60% {
transform: rotate(360deg) translate(0%, 0%) scale(1, 1);
opacity: 1;
}
100% {
transform: rotate(360deg) translate(0%, -100%) scale(1, 5);
opacity: 0;
}
}
Below is the javascript code for this video.
index.js
(function () {
const getRandomArb = (min, max) => Math.random() * (max - min) + min;
function moveHorizontal() {
this.style.left = Math.floor(getRandomArb(5, 95)) + "%";
this.style.top = Math.floor(getRandomArb(100, 120)) + "vh";
}
function createMoreFlowers() {
for (var i = 0; i < 24; i++) {
var delay = getRandomArb(0, 6) + "s";
var ul = document.createElement("ul");
ul.classList.add("floral-popping");
ul.style.left = Math.floor(getRandomArb(5, 95)) + "%";
ul.style.top = Math.floor(getRandomArb(100, 120)) + "vh";
ul.style.animationDelay = delay;
for (var j = 0; j < 6; j++) {
var li = document.createElement("li");
li.classList.add("flower-petal");
li.style.background = "#000000";
li.style.animationDelay = delay;
ul.appendChild(li);
}
document.querySelector(".mask").appendChild(ul);
}
}
createMoreFlowers();
document.querySelectorAll(".floral-popping").forEach(each => each.addEventListener("animationend", moveHorizontal));
})();
Thanks for visiting