Set Multiple CSS Keyframes With jQuery - Keyframes

Set Multiple CSS Keyframes With jQuery - Keyframes

The Keyframes jQuery plugin allows you to dynamically generate customizable, CSS keyframe based animations with callbacks and useful API.

1. Add jQuery JavaScript library and the jQuery Keyframes plugin to the html page.

<script src="" integrity="sha384-xBuQ/xzmlsLoJpyjoggmTEz8OWUFM0/RC5BsqQBDX2v5cMvDHcMakNTNrHIW2I5f" crossorigin="anonymous"></script>
<script src="jquery.keyframes.js"></script>

2. Define new animation sequences (keyframes).

  name: 'ball-move',
  '0%': {
    'margin-left': '0px'
  '50%': {
    'margin-left': '600px'
  '100%': {
    'margin-left': '0px'
}, {
  name: 'ball-spin',
  from: {
    'transform': 'rotate(90deg)'
  to: {
    'transform': 'rotate(450deg)'

3. Play the animations.

// move with easing
  name: 'ball-move',
  duration: "3s",
  timingFunction: 'ease',
  iterationCount: 'infinite',
  direction: 'normal',
  fillMode: 'forwards',
  complete: increment
// run spin keyframes with a callback using the shorthand method.
$('.el').playKeyframe('ball-spin 500ms linear 0s 3 normal forwards', increment);

4. More API methods to control the animations.

// Reset the animation
// Pause the animation
// Resume the animation

This awesome jQuery plugin is developed by Keyframes. For more Advanced Usages, please check the demo page or visit the official website.

  • Publication date: 22.01.2018
  • Source