Indian national flag with CSS Animation
Preview:
HTML Code:
FlagAnimation.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Wave flag</title>
</head>
<body>
<div class="flag">
<!--Chakra png Image center of flag-->
<img src="Ashoka_chakra.png" alt="">
</div>
<!--This is for animation of flag not chakra-->
<svg>
<filter id="wavy">
<feTurbulence x="0" y="0" baseFrequency="0.01" numOctaves="5" seed="2">
<animate attributeName="baseFrequency" dur="60s"
values="0.0.2;0.05;0.02" repeatCount="indefinite"></animate>
</feTurbulence>
<!--waves of flag-->
<feDisplacementMap in="SourceGraphic" scale="30"></feDisplacementMap>
</filter>
</svg>
</body>
</html>
CSS Code:
Style.css
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #000;
}
.flag{
position: relative;
width: 400px;
height: 300px;
display: flex;
justify-content: center;
align-items: center;
-webkit-box-reflect: below 15px linear-gradient(transparent, rgba( 0, 0, 0, 0.2));
}
.flag::before{
content: '';
position: absolute;
width: 100%;
height: 100%;
background: #fff;
border-top: 100px solid #ff9933;
border-bottom: 100px solid #138808;
box-sizing: border-box;
filter: url(#wavy);
}
.flag::after{
content: '';
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 100%;
background: rgba(255, 255, 255, 0.1);
filter: url(#wavy);
}
.flag img{
margin-top: 10px;
position: relative;
max-width: 90px;
z-index: 100;
animation: rotate 15s linear infinite;
}
@keyframes rotate{
0%{
transform: rotate(0deg);
}
100%{
transform: rotate(360deg);
}
}
svg{
width: 0;
height: 0;
}
Download all files from here:
https://drive.google.com/file/d/1P2XTFYACMaDNWZ-MA9JrY6SCjAYoqTfj/view?usp=sharing-
--By CodeStudio