<div class="container">
  <p>Hover over the container to see the elements animate.</p>
  <p>animation timing function applied to entire animation cycle</p>
  <div class="element element-1"></div>
</div>
<div class="container">
  <p>
    Animation timing functions applied to individual keyframes
  </p>
  <div class="element element-2"></div>
</div>
body {
    background-color: #F5F5F5;
    color: #555;
    font-size: 1.1em;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.container {
    margin: 50px auto;
    max-width: 700px;
    padding: 30px;
    border: 1px solid #aaa;
    background-color: white;
}

.element {
    width: 50px;
    height: 50px;
    position: relative;
    top: 0;
    left: 0;
}

.element-1 {
    background-color: #009966;
}

.element-2 {
    background-color: purple;
}

.container:hover .element-1 {
    -webkit-animation-name: zigzag;
    animation-name: zigzag;
    -webkit-animation-duration: 3s;
    animation-duration: 3s;
    -webkit-animation-timing-function: linear;
    animation-timing-function: linear;
}

.container:hover .element-2 {
    -webkit-animation-name: controlled-zigzag;
    animation-name: controlled-zigzag;
    -webkit-animation-duration: 3s;
    animation-duration: 3s;
}

@-webkit-keyframes zigzag {
    from {
        left: 0;
        top: 0;
    }
    15% {
        left: 50px;
        top: -50px;
    }
    30% {
        left: 100px;
        top: 0;
    }
    45% {
        left: 150px;
        top: -50px;
    }
    60% {
        left: 200px;
        top: 0;
    }
    75% {
        left: 250px;
        top: -50px;
    }
    100% {
        left: 300px;
        top: 0;
    }
}

@keyframes zigzag {
    from {
        left: 0;
        top: 0;
    }
    15% {
        left: 50px;
        top: -50px;
    }
    30% {
        left: 100px;
        top: 0;
    }
    45% {
        left: 150px;
        top: -50px;
    }
    60% {
        left: 200px;
        top: 0;
    }
    75% {
        left: 250px;
        top: -50px;
    }
    100% {
        left: 300px;
        top: 0;
    }
}

@-webkit-keyframes controlled-zigzag {
    from {
        left: 0;
        top: 0;
        -webkit-animation-timing-function: ease-out;
        animation-timing-function: ease-out;
    }
    15% {
        left: 50px;
        top: -50px;
        -webkit-animation-timing-function: ease-in;
        animation-timing-function: ease-in;
    }
    30% {
        left: 100px;
        top: 0;
        -webkit-animation-timing-function: ease-out;
        animation-timing-function: ease-out;
    }
    45% {
        left: 150px;
        top: -50px;
        -webkit-animation-timing-function: ease-in;
        animation-timing-function: ease-in;
    }
    60% {
        left: 200px;
        top: 0;
        -webkit-animation-timing-function: ease-out;
        animation-timing-function: ease-out;
    }
    75% {
        left: 250px;
        top: -50px;
        -webkit-animation-timing-function: ease-in;
        animation-timing-function: ease-in;
    }
    90% {
        left: 300px;
        top: 0;
        -webkit-animation-timing-function: ease-out;
        animation-timing-function: ease-out;
    }
    100% {
        left: 0;
        top: 0;
    }
}

@keyframes controlled-zigzag {
    from {
        left: 0;
        top: 0;
        -webkit-animation-timing-function: ease-out;
        animation-timing-function: ease-out;
    }
    15% {
        left: 50px;
        top: -50px;
        -webkit-animation-timing-function: ease-in;
        animation-timing-function: ease-in;
    }
    30% {
        left: 100px;
        top: 0;
        -webkit-animation-timing-function: ease-out;
        animation-timing-function: ease-out;
    }
    45% {
        left: 150px;
        top: -50px;
        -webkit-animation-timing-function: ease-in;
        animation-timing-function: ease-in;
    }
    60% {
        left: 200px;
        top: 0;
        -webkit-animation-timing-function: ease-out;
        animation-timing-function: ease-out;
    }
    75% {
        left: 250px;
        top: -50px;
        -webkit-animation-timing-function: ease-in;
        animation-timing-function: ease-in;
    }
    90% {
        left: 300px;
        top: 0;
        -webkit-animation-timing-function: ease-out;
        animation-timing-function: ease-out;
    }
    100% {
        left: 0;
        top: 0;
    }
}