CSS - Animation


SUBMITTED BY: onerisgf

DATE: May 3, 2020, 12:18 a.m.

FORMAT: Text only

SIZE: 1.5 kB

HITS: 433

  1. /* keyframes IT IS USED TO CREATE ANIMATION, THEN A NAME IS NEXT.*/
  2. @keyframes animacao-box{
  3. from { /*FROM INDICATES THE STATE OF START OF ANIMATION*/
  4. background: slateblue;
  5. border-radius: 0px;
  6. top: 0px;
  7. left: 0px;
  8. }
  9. to{ /*TO INDICATES THE FINAL STATE OF ANIMATION*/
  10. background: orangered;
  11. border-radius: 300px;
  12. top: 200px;
  13. left: 500px;
  14. }
  15. }
  16. /* IT IS ALSO POSSIBLE TO USE THE ANIMATION TRANSFORMATION AS FOLLOWS:
  17. @keyframes animacao-box {
  18. 0% {top: 0px; left: 0px; background: slateblue; border-radius: 0px;}
  19. 25% {top: 200px; left: 500px; background: orangered; border-radius: 300px;}
  20. 75% {top: 200px; left: 1000px; background: orangered; border-radius: 300px;}
  21. 100% {top: 0px; left: 1000px; background: slateblue; border-radius: 0px;}
  22. }
  23. */
  24. #box-animacao{
  25. width: 300px;
  26. height: 300px;
  27. background: slateblue;
  28. position: relative;
  29. animation-name: animacao-box; /* CALLS ANIMATION CREATED */
  30. animation-duration: 5s; /* ANIMATION TIME*/
  31. animation-delay: 3s; /* WAITING TIME TO START*/
  32. animation-iteration-count: infinite; /* HOW MANY TIMES SHOULD REPEAT*/
  33. animation-direction: alternate; /* THE WAY IT IS REPEATED*/
  34. }
  35. /* YOU CAN ALSO DECLARE ANIMATION AS FOLLOWS:
  36. animation: animacao-box 5s 3s infinite alternate;
  37. */

comments powered by Disqus