HTML/CSS animations playground and showcase.

Transitions

Using Transitions

Transition applied to button properties

  .transformElement {
    transition: all 1s linear;
  }

  /* Example of button color change */
  .buttonColor {
    background-color: #f9008e;
  }
  .buttonColor:hover {
    background-color: #00a940;
  }
      

You can specify transitions for individual properties

  .multiTransformElement{
    transition: background-color, transform;
    transition-duration: 1s, 0.5s;
    transition-delay: 500ms, 1s;
    transition-timing-function: ease-out, ease-in;
    }
    
    .buttonFlip:hover{
      transform: rotateY(180deg) rotateX(180deg);
    }

    .buttonColor:hover {
    background-color: #00a940;
  }
      

Transitions can have different timings and you can activate use Javascript to play with them
I'm a div
linear
I'm a div
ease
I'm a div
ease-in
I'm a div
ease-out
I'm a div
ease-in-out
I'm a div
step-start
I'm a div
step-end
I'm a div
steps(10)
I'm a div
steps(10, start)
I'm a div
steps(10, end)
I'm a div
cubic-bezier

  const ActivateTransitions = () => {
    const elements = document.getElementsByClassName("transformDiv");
    for (let i = 0; i < elements.length; i++) {
      elements[i].classList.add('moveDiv');
    }
  };

  const DeactivateTransitions = () => {
    const elements = document.getElementsByClassName("transformDiv");
    for (let i = 0; i < elements.length; i++) {
      elements[i].classList.remove('moveDiv');
    }
  };      

Animations

Using Animations

Animations have different directions and timings

  .animationButton1{
    animation: basicAnimation 1s ease-out alternate infinite;
  }

  @keyframes basicAnimation {
    0% {
      border-radius: 0%;
    }
    100% {
      border-radius: 50%;
      background-color: #00a940;
    }
  }

  @keyframes basicAnimation {
    from {
      border-radius: 0%;
    }
    to {
      border-radius: 50%;
      background-color: #00a940;
    }
  }

Careful using transition and animation at the same time

  .animationButton {
    transition: all 0.5s ease-out;
    animation: basicAnimation 2s ease-out infinite alternate;
    animation-delay: 2s;
  }

  .animationButton:hover {
    border-radius: 30%;
    background-color: #00a940;
  }
An animation can have multiple steps if you use percentages

  .animationButton10 {
    animation: multiStepAnimation 5s ease-out infinite;
  }

  @keyframes multiStepAnimation {
    0% {
      transform: scale(1) translate(0) rotate(0);
      background-color: green;
    }
    20% {
      transform: scale(1.2) translate(20px, 30px) rotate(90deg);
      background-color: blue;
      color: white;
    }
    40%,
    50% {
      transform: scale(0.5) translate(60px) rotate(-90deg);
      background-color: yellow;
      color: black;
    }
    65% {
      transform: scale(0.5) translate(-150px) rotate(-90deg);
      background-color: red;
      color: white;
    }
    90% {
      transform: scale(0.5) translate(-150px) rotate(-190deg);
      background-color: purple;
    }
    100% {
      transform: scale(1) translate(0) rotate(0);
      background-color: green;
    }
  }
You can also combine animations

  .animationButton {
    animation: borderAnimation 2500ms ease-out alternate infinite,
      rotateAnimation 5s linear forwards,
      colorAnimation 1.1s ease-in alternate-reverse infinite;
    animation-delay: 0s, 1s, 0s;
  }
  
  @keyframes borderAnimation{
    0%{ border-radius: 0%;}
    100%{ border-radius: 100%; }
  }
  @keyframes rotateAnimation{
    0%{ transform: rotate(0); }
    100%{ transform: rotate(150deg); }
  }
  @keyframes colorAnimation{
    0%{ background-color: #f9008e; }
    100%{ background-color:#00a940; }
  }
The sky is the limit!! you can do whatever you want with css animations and transitions

Biblipgraphy