Fireship · @fireship

Make Awesome SVG Animations with CSS // 7 Useful Techniques

Uploaded March 26, 2021 · Length 12:20

Make Awesome SVG Animations with CSS // 7 Useful Techniques

Summary

learn 7 svg animation techniques using css to create interactive web graphics

  • svg animation
  • css animation
  • web graphics
  • interactive design
  • duotone icons
  • vector graphics
  • html css svg

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:01

    combining scalable vector graphics with

  2. 0:03

    css animation

  3. 0:04

    is one of the most powerful techniques

  4. 0:06

    that web designers have at their

  5. 0:07

    disposal to stand out from the

  6. 0:08

    competition

  7. 0:09

    just look at all the amazing animated

  8. 0:11

    duotone icons on the stripe homepage

  9. 0:14

    or this looping animated explainer

  10. 0:15

    sequence on the gatsby homepage

  11. 0:17

    you don't need to be an expert designer

  12. 0:19

    animator or developer to create things

  13. 0:21

    like this

  14. 0:22

    oh that was easy in today's tutorial

  15. 0:24

    you'll build two things an animated icon

  16. 0:26

    the user can interact with and a looping

  17. 0:28

    animated sequence

  18. 0:29

    all of which are powered by just svg and

  19. 0:32

    css

  20. 0:32

    and in the process you'll learn seven

  21. 0:34

    cool techniques that have helped me with

  22. 0:36

    vector graphics on the web over the

  23. 0:37

    years

  24. 0:38

    if you're new here like and subscribe

  25. 0:39

    sadly half the people that watch my

  26. 0:41

    content

  27. 0:41

    aren't actually subscribed yet first of

  28. 0:43

    all what is a scalable vector graphic

  29. 0:45

    well what it isn't is a raster image

  30. 0:47

    like a png or jpeg image that you might

  31. 0:50

    take on your phone

  32. 0:51

    those formats represent an image with a

  33. 0:53

    grid of pixels and that means the

  34. 0:54

    resolution

  35. 0:55

    is dependent on the number of pixels in

  36. 0:57

    the image to get a higher resolution

  37. 0:59

    image

  38. 0:59

    you need a bigger matrix with more

  39. 1:01

    pixels in it in contrast

  40. 1:02

    a vector image uses a totally different

  41. 1:04

    approach that's based on geometry and

  42. 1:06

    math instead of static pixels

  43. 1:08

    if you open an svg file in your editor

  44. 1:10

    you'll notice it looks exactly like html

  45. 1:12

    markup

  46. 1:13

    the svg tag has an attribute called view

  47. 1:15

    box that defines a grid

  48. 1:17

    then any graphics that are computed

  49. 1:18

    inside that grid can be scaled up to any

  50. 1:21

    size

  51. 1:21

    because you're just multiplying the math

  52. 1:23

    in that grid by the image resolution

  53. 1:25

    now inside the svg tags we have a bunch

  54. 1:27

    of different elements

  55. 1:28

    like rect circle and polygon to draw

  56. 1:31

    basic shapes

  57. 1:31

    the shapes have different attributes to

  58. 1:33

    define their xy coordinates and size

  59. 1:35

    then you have the path element which is

  60. 1:37

    the most powerful element in an svg

  61. 1:39

    because it's like having access to an

  62. 1:40

    imaginary pen where you can define any

  63. 1:42

    sequence of lines and curves

  64. 1:44

    now it's good to know what's inside an

  65. 1:45

    svg but you should rarely need to write

  66. 1:47

    the actual graphics code by hand

  67. 1:49

    instead you should be having a graphic

  68. 1:51

    designer do that in a design tool like

  69. 1:53

    figma illustrator or inkscape all of

  70. 1:55

    which can export vector graphics to the

  71. 1:57

    svg format

  72. 1:58

    now once a graphic has been drawn there