Indian National Flag with CSS Animation

 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

*{
    margin0;
    padding0;
    box-sizing: border-box;
}
body{
    display: flex;
    justify-content: center;
    align-items: center;
    min-height100vh;
    background: #000;
}
.flag{
    position: relative;
    width400px;
    height300px;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-box-reflect: below 15px linear-gradient(transparent, rgba( 0000.2));
}
.flag::before{
    content'';
    position: absolute;
    width100%;
    height100%;
    background: #fff;
    border-top100px solid #ff9933;
    border-bottom100px solid #138808;
    box-sizing: border-box;
    filter: url(#wavy);
}
.flag::after{
    content'';
    position: absolute;
    top0;
    left0;
    width50%;
    height100%;
    background: rgba(2552552550.1);
    filter: url(#wavy);
}
.flag img{
    margin-top10px;
    position: relative;
    max-width90px;
    z-index100;
    animation: rotate 15s linear infinite;
}
@keyframes rotate{
    0%{
        transform: rotate(0deg);
    }
    100%{
        transform: rotate(360deg);
    }
}
svg{
    width0;
    height0;
}


Download all files from here:

https://drive.google.com/file/d/1P2XTFYACMaDNWZ-MA9JrY6SCjAYoqTfj/view?usp=sharing-

--By CodeStudio

CodeStudio

Hi, I am Mayur Dehade. I am a Computer Engineering student, Web Developer, Programmer, and also blogger. On this CodeStudio blog, I have uploaded new and interesting coding-related posts and material like notes and provide a full code file.

Post a Comment (0)
Previous Post Next Post