<h2>CSS Animations: the <code>animation-timing-function</code> Keywords</h2>

  <p>Use the inputs below to set a duration for the animation. You can choose to define the duration using seconds or milliseconds.</p>

  <div class="box">
  <label for="timing">Set a timing function:</label>
  <select id="timing">
    <option value="ease">ease</option>
    <option value="ease-in">ease-in</option>
    <option value="ease-out">ease-out</option>
    <option value="ease-in-out">ease-in-out</option>
    <option value="linear">linear</option>
    <option value="step-start">step-start</option>
    <option value="step-end">step-end</option>


  <button>Animate the Box</button> <button disabled>Reset</button>

body {
  font-family: Arial, sans-serif;
  font-size: 20px;
  padding: 0 20px;

main {
  text-align: center;
  margin: 0 auto;
  max-width: 800px;

p {
  text-align: left;
  padding: 0 20px;

code {
  color: firebrick;

.box {
  width: 100px;
  height: 100px;
  background: lightpink;
  border: solid 2px;
  margin-bottom: 20px;

.box-animate {
  animation-name: moveObject;
  animation-duration: 2s;
  animation-fill-mode: forwards;

@keyframes moveObject {
  from {
    transform: translateX(0);

  to {
    transform: translateX(600px);

input[type=number] {
  width: 100px;  

button {
  margin-top: 20px;
let myObject = document.querySelector('.box'),
    btn1 = document.querySelector('button'),
    btn2 = document.querySelectorAll('button')[1];

btn1.addEventListener('click', function () {
  myObject.style.animationTimingFunction = document.querySelector('#timing').value;
  this.disabled = true;
  btn2.disabled = false;
}, false);

btn2.addEventListener('click', function () {
  this.disabled = true;
  btn1.disabled = false;
}, false);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.