본문 바로가기

Webstoryboy

Category

Explanation

REFERENCE/CSS

[CSS] animation

animation

animation 속성은 애니메이션을 설정합니다. 컨텐츠 요소를 움직이게 할 수 있으며, 움직이는 시간, 움직이는 방향, 움직이는 상태 등 여러가지 속성을 설정할 수 있습니다.


animation

animation 속성은 애니메이션을 정의합니다.

정의(Definition)

  • animation 속성은 애니메이션을 정의합니다.

문법(Syntax)

animation: name | duration | timing-function | delay | iteration-count | direction | fill-mode | play-state;

속성(Property)

속성값 설명
name 애니메이션 keyframe 이름을 설정합니다.
duration 애니메이션 움직임 시간을 설정합니다.
timing-function 애니메이션 움직임 속도를 정의합니다.
delay 애니메이션이 로드된 후 애니메이션이 시작될 때 까지의 시간을 나타냅니다.
iteration-count 애니메이션 반복 횟수 설정합니다.
direction 애니메이션 움직임 방향을 설정합니다.
fill-mode 애니메이션이 끝난 후의 상태를 설정합니다.
play-state 애니메이션 진행상태를 설정합니다.

Sample1

기본적인 CSS 애니메이션 예제입니다.

결과
TOTAL
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Animation</title>
    <style>
        /* option */
        .animation {
            background-color: #f7f7f7;
            border-radius: 3px;
            padding: 20px;
            counter-reset: items;
        }
        .box {
            position: relative;
            width: 60px; height: 60px; line-height: 60px;
            text-align: center; color: #fff; font-size: 12px;
            margin: 10px;
            border-radius: 50%;
            background-color: #A2CBFA;
            border: 1px solid #4390E1;
            box-shadow: 0 2px 2px rgba(0,90,250,0.05), 0 4px 4px rgba(0,90,250,0.05), 0 8px 8px rgba(0,90,250,0.05), 0 16px 16px rgba(0,90,250,0.05);
        }
        .box::before {
            counter-increment: items;
            content: counter(items);
        }
        .choice > a{    
            border: 1px solid #5f6368;
            padding: 7px 20px 5px 20px;
            display: inline-block;
            border-radius: 20px;
            text-decoration: none;
            margin: 3px;
        }
        /* animation */
        .box1:nth-child(1).show {animation: move 2s 1;}
        .box1:nth-child(2).show {animation: move 2s 1;}
        .box1:nth-child(3).show {animation: move 2s 1;}

        @keyframes move {
            0%   {left: 0%;}
            50%  {left: calc(100% - 70px);}
            100% {left: 0%;}
        }
    </style>
</head>
<body>
    
    <div class="animation ani1">
        <div class="box box1"></div>
        <div class="box box1"></div>
        <div class="box box1"></div>
    </div>

    <div class="choice choice1">
        <a href="#" class="reset1">리셋</a>
        <a href="#" class="start1">클릭</a>
    </div>

    <!-- script -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
        $(".choice1 .reset1").on("click",function(e){
            e.preventDefault();
            $(".ani1 > div").removeClass("show");
        });

        $(".choice1 .start1").click(function(e){
            e.preventDefault();
            $(".ani1 > div").eq(0).addClass("show");
            $(".ani1 > div").eq(1).addClass("show");
            $(".ani1 > div").eq(2).addClass("show");
        });
    </script>
</body>
</html>

Sample2

CSS 움직임 효과 애니메이션 예제입니다.

결과
TOTAL
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Animation</title>
    <style>
        /* option */
        .animation {
            background-color: #f7f7f7;
            border-radius: 3px;
            padding: 20px;
            counter-reset: items;
        }
        .box {
            position: relative;
            width: 60px; height: 60px; line-height: 60px;
            text-align: center; color: #fff; font-size: 12px;
            margin: 10px;
            border-radius: 50%;
            background-color: #A2CBFA;
            border: 1px solid #4390E1;
            box-shadow: 0 2px 2px rgba(0,90,250,0.05), 0 4px 4px rgba(0,90,250,0.05), 0 8px 8px rgba(0,90,250,0.05), 0 16px 16px rgba(0,90,250,0.05);
        }
        .box::before {
            counter-increment: items;
            content: counter(items);
        }
        .choice > a{    
            border: 1px solid #5f6368;
            padding: 7px 20px 5px 20px;
            display: inline-block;
            border-radius: 20px;
            text-decoration: none;
            margin: 3px;
        }
        /* animation */
        .box2:nth-child(1).show {animation: move 2s 1 linear;}
        .box2:nth-child(2).show {animation: move 2s 1 ease;}
        .box2:nth-child(3).show {animation: move 2s 1 ease-in;}
        .box2:nth-child(4).show {animation: move 2s 1 ease-out;}
        .box2:nth-child(5).show {animation: move 2s 1 ease-in-out;}

        @keyframes move {
            0%   {left: 0%;}
            50%  {left: calc(100% - 80px);}
            100% {left: 0%;}
        }
    </style>
</head>
<body>
    
    <div class="animation ani2">
        <div class="box box2"></div>
        <div class="box box2"></div>
        <div class="box box2"></div>
        <div class="box box2"></div>
        <div class="box box2"></div>
    </div>

    <div class="choice choice2">
        <a href="#" class="reset2">reset</a>
        <a href="#" class="start2">클릭</a>
    </div>

    <!-- script -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
        $(".choice2 .reset2").on("click",function(e){
            e.preventDefault();
            $(".ani2 > div").removeClass("show");
        });

        $(".choice2 .start2").click(function(e){
            e.preventDefault();
            $(".ani2 > div").eq(0).addClass("show");
            $(".ani2 > div").eq(1).addClass("show");
            $(".ani2 > div").eq(2).addClass("show");
            $(".ani2 > div").eq(3).addClass("show");
            $(".ani2 > div").eq(4).addClass("show");
        });
    </script>
</body>
</html>

Sample3

CSS 움직임 효과 애니메이션 예제입니다.

결과
TOTAL
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Animation</title>
    <style>
        /* option */
        .animation {
            background-color: #f7f7f7;
            border-radius: 3px;
            padding: 20px;
            counter-reset: items;
        }
        .box {
            position: relative;
            width: 60px; height: 60px; line-height: 60px;
            text-align: center; color: #fff; font-size: 12px;
            margin: 10px;
            border-radius: 50%;
            background-color: #A2CBFA;
            border: 1px solid #4390E1;
            box-shadow: 0 2px 2px rgba(0,90,250,0.05), 0 4px 4px rgba(0,90,250,0.05), 0 8px 8px rgba(0,90,250,0.05), 0 16px 16px rgba(0,90,250,0.05);
        }
        .box::before {
            counter-increment: items;
            content: counter(items);
        }
        .choice > a{    
            border: 1px solid #5f6368;
            padding: 7px 20px 5px 20px;
            display: inline-block;
            border-radius: 20px;
            text-decoration: none;
            margin: 3px;
        }
        /* animation */
        .box3:nth-child(1).show {animation: move 3s 1 step-start}
        .box3:nth-child(2).show {animation: move 3s 1 step-end}
        .box3:nth-child(3).show {animation: move 3s 1 steps(4, start)}
        .box3:nth-child(4).show {animation: move 3s 1 steps(4, end)}
        .box3:nth-child(5).show {animation: move 3s 1 steps(10, start)}
        .box3:nth-child(6).show {animation: move 3s 1 steps(10, end)}

        @keyframes move {
            0%   {left: 0%}
            50%  {left: calc(100% - 80px)}
            100% {left: 0%}
        }
    </style>
</head>
<body>
    
    <div class="animation ani3">
        <div class="box box3"></div>
        <div class="box box3"></div>
        <div class="box box3"></div>
        <div class="box box3"></div>
        <div class="box box3"></div>
        <div class="box box3"></div>
    </div>

    <div class="choice choice3">
        <a href="#" class="reset3">reset</a>
        <a href="#" class="start3">클릭</a>
    </div>

    <!-- script -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
        $(".choice3 .reset3").on("click",function(e){
            e.preventDefault();
            $(".ani3 > div").removeClass("show");
        });

        $(".choice3 .start3").click(function(e){
            e.preventDefault();
            $(".ani3 > div").eq(0).addClass("show");
            $(".ani3 > div").eq(1).addClass("show");
            $(".ani3 > div").eq(2).addClass("show");
            $(".ani3 > div").eq(3).addClass("show");
            $(".ani3 > div").eq(4).addClass("show");
        });
    </script>
</body>
</html>

Sample4

CSS 움직임 cubic bezier 효과 애니메이션 예제입니다.

결과
TOTAL
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Animation</title>
    <style>
        /* option */
        .animation {
            background-color: #f7f7f7;
            border-radius: 3px;
            padding: 20px;
            counter-reset: items;
        }
        .box {
            position: relative;
            width: 60px; height: 60px; line-height: 60px;
            text-align: center; color: #fff; font-size: 12px;
            margin: 10px;
            border-radius: 50%;
            background-color: #A2CBFA;
            border: 1px solid #4390E1;
            box-shadow: 0 2px 2px rgba(0,90,250,0.05), 0 4px 4px rgba(0,90,250,0.05), 0 8px 8px rgba(0,90,250,0.05), 0 16px 16px rgba(0,90,250,0.05);
        }
        .box::before {
            counter-increment: items;
            content: counter(items);
        }
        .choice > a{    
            border: 1px solid #5f6368;
            padding: 7px 20px 5px 20px;
            display: inline-block;
            border-radius: 20px;
            text-decoration: none;
            margin: 3px;
        }
        /* animation */
        .box4:nth-child(1).show {animation: move 3s .1s cubic-bezier(0,.73,.25,1.01) }
        .box4:nth-child(2).show {animation: move 3s .2s cubic-bezier(0,.73,.82,1.53) }
        .box4:nth-child(3).show {animation: move 3s .3s cubic-bezier(0,.73,1,.02) }
        .box4:nth-child(4).show {animation: move 3s .3s cubic-bezier(.68,0,1,.02) }
        .box4:nth-child(5).show {animation: move 3s .3s cubic-bezier(1,-0.51,.64,.34) }

        @keyframes move {
            0%   {left: 0%}
            50%  {left: calc(100% - 80px)}
            100% {left: 0%}
        }
    </style>
</head>
<body>
    
    <div class="animation ani4">
        <div class="box box4"></div>
        <div class="box box4"></div>
        <div class="box box4"></div>
        <div class="box box4"></div>
        <div class="box box4"></div>
    </div>

    <div class="choice choice4">
        <a href="#" class="reset4">reset</a>
        <a href="#" class="start4">클릭</a>
    </div>

    <!-- script -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
        $(".choice4 .reset4").on("click",function(e){
            e.preventDefault();
            $(".ani4 > div").removeClass("show");
        });

        $(".choice4 .start4").click(function(e){
            e.preventDefault();
            $(".ani4 > div").eq(0).addClass("show");
            $(".ani4 > div").eq(1).addClass("show");
            $(".ani4 > div").eq(2).addClass("show");
            $(".ani4 > div").eq(3).addClass("show");
            $(".ani4 > div").eq(4).addClass("show");
        });
    </script>
</body>
</html>

Sample5

delay 효과 애니메이션 예제입니다.

결과
TOTAL
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Animation</title>
    <style>
        /* option */
        .animation {
            background-color: #f7f7f7;
            border-radius: 3px;
            padding: 20px;
            counter-reset: items;
        }
        .box {
            position: relative;
            width: 60px; height: 60px; line-height: 60px;
            text-align: center; color: #fff; font-size: 12px;
            margin: 10px;
            border-radius: 50%;
            background-color: #A2CBFA;
            border: 1px solid #4390E1;
            box-shadow: 0 2px 2px rgba(0,90,250,0.05), 0 4px 4px rgba(0,90,250,0.05), 0 8px 8px rgba(0,90,250,0.05), 0 16px 16px rgba(0,90,250,0.05);
        }
        .box::before {
            counter-increment: items;
            content: counter(items);
        }
        .choice > a{    
            border: 1px solid #5f6368;
            padding: 7px 20px 5px 20px;
            display: inline-block;
            border-radius: 20px;
            text-decoration: none;
            margin: 3px;
        }
        /* animation */
        .box5:nth-child(1).show {animation: move 3s .1s 1}
        .box5:nth-child(2).show {animation: move 3s .2s 1}
        .box5:nth-child(3).show {animation: move 3s .3s 1}

        @keyframes move {
            0%   {left: 0%}
            50%  {left: calc(100% - 80px)}
            100% {left: 0%}
        }
    </style>
</head>
<body>
    
    <div class="animation ani5">
        <div class="box box5"></div>
        <div class="box box5"></div>
        <div class="box box5"></div>
    </div>

    <div class="choice choice5">
        <a href="#" class="reset5">reset</a>
        <a href="#" class="start5">클릭</a>
    </div>

    <!-- script -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
        $(".choice5 .reset5").on("click",function(e){
            e.preventDefault();
            $(".ani5 > div").removeClass("show");
        });

        $(".choice5 .start5").click(function(e){
            e.preventDefault();
            $(".ani5 > div").eq(0).addClass("show");
            $(".ani5 > div").eq(1).addClass("show");
            $(".ani5 > div").eq(2).addClass("show");
        });
    </script>
</body>
</html>

Sample6

duration 효과 애니메이션 예제입니다.

결과
TOTAL
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Animation</title>
    <style>
        /* option */
        .animation {
            background-color: #f7f7f7;
            border-radius: 3px;
            padding: 20px;
            counter-reset: items;
        }
        .box {
            position: relative;
            width: 60px; height: 60px; line-height: 60px;
            text-align: center; color: #fff; font-size: 12px;
            margin: 10px;
            border-radius: 50%;
            background-color: #A2CBFA;
            border: 1px solid #4390E1;
            box-shadow: 0 2px 2px rgba(0,90,250,0.05), 0 4px 4px rgba(0,90,250,0.05), 0 8px 8px rgba(0,90,250,0.05), 0 16px 16px rgba(0,90,250,0.05);
        }
        .box::before {
            counter-increment: items;
            content: counter(items);
        }
        .choice > a{    
            border: 1px solid #5f6368;
            padding: 7px 20px 5px 20px;
            display: inline-block;
            border-radius: 20px;
            text-decoration: none;
            margin: 3px;
        }
        /* animation */
        .box6:nth-child(1).show {animation: move 3s .1s 1}
        .box6:nth-child(2).show {animation: move 4s .2s 1}
        .box6:nth-child(3).show {animation: move 5s .3s 1}

        @keyframes move {
            0%   {left: 0%}
            50%  {left: calc(100% - 80px)}
            100% {left: 0%}
        }
    </style>
</head>
<body>
    
    <div class="animation ani6">
        <div class="box box6"></div>
        <div class="box box6"></div>
        <div class="box box6"></div>
    </div>

    <div class="choice choice6">
        <a href="#" class="reset6">reset</a>
        <a href="#" class="start6">클릭</a>
    </div>

    <!-- script -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
        $(".choice6 .reset6").on("click",function(e){
            e.preventDefault();
            $(".ani6 > div").removeClass("show");
        });

        $(".choice6 .start6").click(function(e){
            e.preventDefault();
            $(".ani6 > div").eq(0).addClass("show");
            $(".ani6 > div").eq(1).addClass("show");
            $(".ani6 > div").eq(2).addClass("show");
        });
    </script>
</body>
</html>

Sample7

animation-iteration-count 효과 애니메이션 예제입니다.

결과
TOTAL
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Animation</title>
    <style>
        /* option */
        .animation {
            background-color: #f7f7f7;
            border-radius: 3px;
            padding: 20px;
            counter-reset: items;
        }
        .box {
            position: relative;
            width: 60px; height: 60px; line-height: 60px;
            text-align: center; color: #fff; font-size: 12px;
            margin: 10px;
            border-radius: 50%;
            background-color: #A2CBFA;
            border: 1px solid #4390E1;
            box-shadow: 0 2px 2px rgba(0,90,250,0.05), 0 4px 4px rgba(0,90,250,0.05), 0 8px 8px rgba(0,90,250,0.05), 0 16px 16px rgba(0,90,250,0.05);
        }
        .box::before {
            counter-increment: items;
            content: counter(items);
        }
        .choice > a{    
            border: 1px solid #5f6368;
            padding: 7px 20px 5px 20px;
            display: inline-block;
            border-radius: 20px;
            text-decoration: none;
            margin: 3px;
        }
        /* animation */
        .box7:nth-child(1).show {animation: move 2s 1}
        .box7:nth-child(2).show {animation: move 2s 2}
        .box7:nth-child(3).show {animation: move 2s 3}

        @keyframes move {
            0%   {left: 0%}
            50%  {left: calc(100% - 80px)}
            100% {left: 0%}
        }
    </style>
</head>
<body>
    
    <div class="animation ani7">
        <div class="box box7"></div>
        <div class="box box7"></div>
        <div class="box box7"></div>
    </div>

    <div class="choice choice7">
        <a href="#" class="reset7">reset</a>
        <a href="#" class="start7">클릭</a>
    </div>

    <!-- script -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
        $(".choice7 .reset7").on("click",function(e){
            e.preventDefault();
            $(".ani7 > div").removeClass("show");
        });

        $(".choice7 .start7").click(function(e){
            e.preventDefault();
            $(".ani7 > div").eq(0).addClass("show");
            $(".ani7 > div").eq(1).addClass("show");
            $(".ani7 > div").eq(2).addClass("show");
        });
    </script>
</body>
</html>

Sample8

animation-fill-mode 효과 애니메이션 예제입니다.

결과
TOTAL
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Animation</title>
    <style>
        /* option */
        .animation {
            background-color: #f7f7f7;
            border-radius: 3px;
            padding: 20px;
            counter-reset: items;
        }
        .box {
            position: relative;
            width: 60px; height: 60px; line-height: 60px;
            text-align: center; color: #fff; font-size: 12px;
            margin: 10px;
            border-radius: 50%;
            background-color: #A2CBFA;
            border: 1px solid #4390E1;
            box-shadow: 0 2px 2px rgba(0,90,250,0.05), 0 4px 4px rgba(0,90,250,0.05), 0 8px 8px rgba(0,90,250,0.05), 0 16px 16px rgba(0,90,250,0.05);
        }
        .box::before {
            counter-increment: items;
            content: counter(items);
        }
        .choice > a{    
            border: 1px solid #5f6368;
            padding: 7px 20px 5px 20px;
            display: inline-block;
            border-radius: 20px;
            text-decoration: none;
            margin: 3px;
        }
        /* animation */
        .box8:nth-child(1).show {animation: move1 2s 1 none}
        .box8:nth-child(2).show {animation: move1 2s 1 forwards}
        .box8:nth-child(3).show {animation: move1 2s 1 backwards}
        .box8:nth-child(4).show {animation: move1 2s 1 both}

        @keyframes move1 {
            0%   {left: 0%}
            100%  {left: calc(100% - 80px)}
        }
    </style>
</head>
<body>
    
    <div class="animation ani8">
        <div class="box box8"></div>
        <div class="box box8"></div>
        <div class="box box8"></div>
        <div class="box box8"></div>
    </div>

    <div class="choice choice8">
        <a href="#" class="reset8">reset</a>
        <a href="#" class="start8">클릭</a>
    </div>

    <!-- script -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
        $(".choice8 .reset8").on("click",function(e){
            e.preventDefault();
            $(".ani8 > div").removeClass("show");
        });

        $(".choice8 .start8").click(function(e){
            e.preventDefault();
            $(".ani8 > div").eq(0).addClass("show");
            $(".ani8 > div").eq(1).addClass("show");
            $(".ani8 > div").eq(2).addClass("show");
            $(".ani8 > div").eq(3).addClass("show");
        });
    </script>
</body>
</html>

Sample9

animation-fill-mode 효과 애니메이션 예제입니다.

결과
TOTAL
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Animation</title>
    <style>
        /* option */
        .animation {
            background-color: #f7f7f7;
            border-radius: 3px;
            padding: 20px;
            counter-reset: items;
        }
        .box {
            position: relative;
            width: 60px; height: 60px; line-height: 60px;
            text-align: center; color: #fff; font-size: 12px;
            margin: 10px;
            border-radius: 50%;
            background-color: #A2CBFA;
            border: 1px solid #4390E1;
            box-shadow: 0 2px 2px rgba(0,90,250,0.05), 0 4px 4px rgba(0,90,250,0.05), 0 8px 8px rgba(0,90,250,0.05), 0 16px 16px rgba(0,90,250,0.05);
        }
        .box::before {
            counter-increment: items;
            content: counter(items);
        }
        .choice > a{    
            border: 1px solid #5f6368;
            padding: 7px 20px 5px 20px;
            display: inline-block;
            border-radius: 20px;
            text-decoration: none;
            margin: 3px;
        }
        /* animation */
        .ani9 {height: 300px;}
        .ani9 > div.running {animation: move2 3s 10 ease running;}
        .ani9 > div.paused {animation: move2 3s 10 ease paused;}
            
        @keyframes move2 {
            0%   {left:0; top:0;}
            25%  {left: calc(100% - 80px); top:0;}
            50%  {left: calc(100% - 80px); top: calc(100% - 80px);}
            75%  {left: 0; top: calc(100% - 80px);}
            100% {left:0; top:0;}
        }
    </style>
</head>
<body>
    
    <div class="animation ani9">
        <div class="box box9"></div>
    </div>

    <div class="choice choice9">
        <a href="#" class="reset9">running</a>
        <a href="#" class="start9">paused</a>
    </div>

    <!-- script -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
        $(".choice9 a").click(function(e){
            e.preventDefault();
            var text = $(this).text();     
            $(".ani9 > div").removeClass().addClass("box box9").addClass(text);
        });
    </script>
</body>
</html>

Sample10

animation-direction 효과 애니메이션 예제입니다.

TOTAL
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Animation</title>
    <style>
        /* option */
        .animation {
            background-color: #f7f7f7;
            border-radius: 3px;
            padding: 20px;
            counter-reset: items;
        }
        .box {
            position: relative;
            width: 60px; height: 60px; line-height: 60px;
            text-align: center; color: #fff; font-size: 12px;
            margin: 10px;
            border-radius: 50%;
            background-color: #A2CBFA;
            border: 1px solid #4390E1;
            box-shadow: 0 2px 2px rgba(0,90,250,0.05), 0 4px 4px rgba(0,90,250,0.05), 0 8px 8px rgba(0,90,250,0.05), 0 16px 16px rgba(0,90,250,0.05);
        }
        .box::before {
            counter-increment: items;
            content: counter(items);
        }
        .choice > a{    
            border: 1px solid #5f6368;
            padding: 7px 20px 5px 20px;
            display: inline-block;
            border-radius: 20px;
            text-decoration: none;
            margin: 3px;
        }
        /* animation */
        .ani10 {height: 300px;}
        .ani10 > div.normal {animation: move2 3s 10 ease normal;}
        .ani10 > div.reverse {animation: move2 3s 10 ease reverse;}
        .ani10 > div.alternate {animation: move2 3s 10 ease alternate;}
        .ani10 > div.alternate-reverse {animation: move2 3s 10 ease alternate-reverse;}
            
        @keyframes move2 {
            0%   {left:0; top:0;}
            25%  {left: calc(100% - 80px); top:0;}
            50%  {left: calc(100% - 80px); top: calc(100% - 80px);}
            75%  {left: 0; top: calc(100% - 80px);}
            100% {left:0; top:0;}
        }
    </style>
</head>
<body>
    
    <div class="animation ani10">
        <div class="box box10"></div>
    </div>

    <div class="choice choice10">
        <a href="#" class="start10">normal</a>
        <a href="#" class="start10">reverse</a>
        <a href="#" class="start10">alternate</a>
        <a href="#" class="start10">alternate-reverse</a>
    </div>

    <!-- script -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
        $(".choice10 a").click(function(e){
            e.preventDefault();
            var text = $(this).text();     
            $(".ani10 > div").removeClass().addClass("box box10").addClass(text);
        });
    </script>
</body>
</html>

호환성(Compatibility) 더보기 caniuse.com

크롬 아이콘 파이어폭스 아이콘 사파리 아이콘 오페라 아이콘 네이버 웨일 익스플로러6 아이콘6 익스플로러7 아이콘7 익스플로러8 아이콘8 익스플로러9 아이콘9 익스플로러10 아이콘10 익스플로러11 아이콘11 엣지 아이콘 안드로이드 아이콘 ios 아이콘
animation 사용가능 사용가능 사용가능 사용가능 사용가능 사용안됨 사용안됨 사용안됨 사용안됨 사용가능 사용가능 사용가능 사용가능 사용가능
name 사용가능 사용가능 사용가능 사용가능 사용가능 사용안됨 사용안됨 사용안됨 사용안됨 사용가능 사용가능 사용가능 사용가능 사용가능
duration 사용가능 사용가능 사용가능 사용가능 사용가능 사용안됨 사용안됨 사용안됨 사용안됨 사용가능 사용가능 사용가능 사용가능 사용가능
timing-function 사용가능 사용가능 사용가능 사용가능 사용가능 사용안됨 사용안됨 사용안됨 사용안됨 사용가능 사용가능 사용가능 사용가능 사용가능
delay 사용가능 사용가능 사용가능 사용가능 사용가능 사용안됨 사용안됨 사용안됨 사용안됨 사용가능 사용가능 사용가능 사용가능 사용가능
iteration-count 사용가능 사용가능 사용가능 사용가능 사용가능 사용안됨 사용안됨 사용안됨 사용안됨 사용가능 사용가능 사용가능 사용가능 사용가능
direction 사용가능 사용가능 사용가능 사용가능 사용가능 사용안됨 사용안됨 사용안됨 사용안됨 사용가능 사용가능 사용가능 사용가능 사용가능
fill-mode 사용가능 사용가능 사용가능 사용가능 사용가능 사용안됨 사용안됨 사용안됨 사용안됨 사용가능 사용가능 사용가능 사용가능 사용가능
play-state 사용가능 사용가능 사용가능 사용가능 사용가능 사용안됨 사용안됨 사용안됨 사용안됨 사용가능 사용가능 사용가능 사용가능 사용가능

참고(Reference)

  • MDN
  • CSS Animations

Tag

AD

comments