css animation on click


<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<style>
    @keyframes beat {
        0% {
            -webkit-transform: scale(1, 1);
            transform: scale(1, 1);
        }
        100% {
            -webkit-transform: scale(0.8,0.8);
            transform: scale(0.8, 0.8);
        }
    }
    .className {
        background-color:#07d;
        color: #fff;
        font-family: sans-serif;
        font-size: 20px;
        padding: 20px;
        margin:5px;
        -webkit-transform: scale(1, 1);
        transform: scale(1, 1);
    }
    .className:focus {
        -webkit-animation: beat 1s ease-in-out backwards;
        animation: beat 1s ease-in-out backwards;
    }
    .className:active {
        -webkit-animation: none;
        animation: none;
    }
    body {
        text-align: center;
    }
</style>
<h3>Any element with tabindex="0", like a div:</h3>
<div tabindex="0" class="className"> Click me many times!</div>
<h3>Any focusable element like a button:</h3>
<button class="className"> Click me many times!</button>
</body>
</html>