WEB(웹)/css

css @keyframes

SharingWorld 2018. 10. 27. 08:22

@keyframes

애니메이션 효과를 진행 속도나 단계를 직접 지정할 때 사용합니다.

<!DOCTYPE html>
<html>
<head>
    <title>13-02</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        .box {
            background-color: blue;
            width: 50px;
            height: 50px;
            position: absolute;
            top: 20px;
            left: 30px;
        }

        @keyframes shake-box {
            0% {
                transform: translateX(-20px);
                background-color: blue;
            }
            50% {
                transform: translateX(10px);
                background-color: yellow;
            }
            100% {
                transform: translateX(-20px);
                background-color: blue;
            }
        }

        .box:hover {
            animation: shake-box 0.2s infinite;
        }
    </style>
</head>
<body>
<div class="box"></div>
</body>
</html>


출처 : vue.js quickstart