비전공자 개발일기

Elastic Line Animation 본문

HTML _CSS

Elastic Line Animation

HiroDaegu 2022. 12. 18. 00:53
728x90
SMALL

Elastic Line Animation

 

실제 동작 영상
<!DOCTYPE html>
<html lang="ko">
<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>CSS ELASTIC LINE ANIMATION</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="elastic">
        <div class="ball"></div>
        <svg>
            <path></path>
        </svg>
        <svg>
            <path></path>
        </svg>
    </div>
</body>
</html>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    position: relative;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #111;
}

.elastic {
    width: 400px;
    height: 400px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.elastic::before {
    content: '';
    position: absolute;
    bottom: 62.5px;
    left: 5px;
    width: 15px;
    height: 15px;
    background-color: #FFF;
    border-radius: 50%;
    z-index: 1;
}

.elastic::after {
    content: '';
    position: absolute;
    bottom: 62.5px;
    right: 5px;
    width: 15px;
    height: 15px;
    background-color: #FFF;
    border-radius: 50%;
    z-index: 1;
}

.elastic svg {
    position: absolute;
    width: 400px;
    height: 150px;
    fill: none;
}

.elastic svg:nth-child(2) {
    filter: blur(25px);
}

.elastic svg path {
    width: 100%;
    stroke: #FF0092;
    stroke-width: 10;
    stroke-linecap: round;
    d: path("M 10 80 Q 190 80 390 80");
    animation: animate 2.5s linear infinite, animateColor 2.5s linear infinite;
}

@keyframes animate {
    0% {
        d: path("M 10 80 Q 190 80 390 80");
    }
    10% {
        d: path("M 10 80 Q 190 160 390 80");
    }
    20% {
        d: path("M 10 80 Q 190 20 390 80");
    }
    30% {
        d: path("M 10 80 Q 190 120 390 80");
    }
    35% {
        d: path("M 10 80 Q 190 100 390 80");
    }
    40% {
        d: path("M 10 80 Q 190 80 390 80");
    }
    50% {
        d: path("M 10 80 Q 190 100 390 80");
    }
    55% {
        d: path("M 10 80 Q 190 90 390 80");
    }
    60% {
        d: path("M 10 80 Q 190 80 390 80");
    }
}

@keyframes animateColor {
    0%, 100% {
        stroke: #FF0092;
    }
    33.33% {
        stroke: #0F0;
    }
    66.66% {
        stroke: #FF0;
    }
}

.elastic .ball {
    width: 60px;
    height: 60px;
    background-color: #FFF;
    border-radius: 50%;
    box-shadow: inset 0 -15px 20px rgba(0, 0, 0, .5);
    animation: animateBall 2.5s linear infinite;
}

@keyframes animateBall {
    0%, 100% {
        transform: translateY(-72.5px);
    }
    10%, 11.5% {
        transform: translateY(-40px);
    }
    50% {
        transform: translateY(-350px);
    }
}
728x90
LIST

'HTML _CSS' 카테고리의 다른 글

Noisy Grainy Icons  (0) 2022.12.21
Credit Card2  (0) 2022.12.19
Create Hover Effect  (0) 2022.12.12
Infinite Ticker  (0) 2022.12.10
3D Flip Product Card  (0) 2022.12.05