Gradient Border Animation

Home / Web Code Snippet / Gradient Border Animation

Gradient Border Animation


https://youtube.com/shorts/jUW6e967i6w?si=ULpuVC8O7qW9up9q

HTML CODE:-

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
</head>
<body>
    <div class="container">
        <img src="https://media.istockphoto.com/id/1090085756/photo/3d-rendering-deer-with-lines.jpg?s=612x612&w=0&k=20&c=sbPwH7vdZSBROn8DAP51ZCCdKFo4dcbjiLLKvf8ApMQ=" width="100%" height="100%">
    </div>
</body>
</html>

CSS CODE:-

body{
    padding: 0px;
    margin: 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: black;
}
img{
    width: 100%;
    height: 100%;
}
.container{
    position: relative;
    width: 400px;
    height: 250px;
}
.container:before, .container:after{
    content: "";
    position: absolute;
    left: -2px;
    top: -2px;
    background: linear-gradient(45deg,#f44336,#fb0094,#fbf700,#00ce24,#0031ce,
    #f44336,#fb0094,#fbf700,#00ce24,#0031ce);
    background-size: 200%;
    width: calc(100% + 5px);
    height: calc(100% + 5px);
    z-index: -1;
    animation: animate 10s linear infinite;
}
@keyframes animate{
    0%{
        background-position: 0 0;
    }
    50%{
        background-position: 200% 0;
    }
    100%{
        background-position: 0 0;
    }
}
.container:after{
    filter: blur(50px);
}