Perfomant CSS animation for beginners

As a general rule, there are only four properties which you can animate whilst maintaining a silky smooth experience for your users. They are: Opacity, Translate, Scale & Rotation. You'll be surprised what you can achieve with only these parameters. Animating 'fixed' elements can result in a screen 're-paint' and a 'janky' transition.
Here, I've chosen to use jQuery to toggle classes because it's eaiser for begininers to read, but I would recommend handling such simple animations with 'vanilla' Javascript.


/* the box in its original state*/
.box {
  transition: all 300ms;
}

/* with opacity class */
.box.removeOpacity {
  opacity: 0;
}

/* with translate class */
.box.moveX {
  transform: translateX(100px);
}

/* with scale class */
.box.scale {
   transform: scale(0.4);
}

/* with rotate class */
.box.rotate {
  transform: rotate(45deg);
}