Fireship · @fireship
CSS Animation in 100 Seconds
Uploaded April 21, 2020 · Length 2:05
Summary
learn how to create css animations with transitions and keyframes in 100 seconds
- css animation
- css transitions
- keyframes animation
- css easing
- css animation tutorial
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
animation it's the change from one CSS
- 0:02
style to another over the dimension of
- 0:04
time every animation has at least two
- 0:05
states a starting point and an ending
- 0:07
point when you move from start to finish
- 0:09
CSS will calculate all the values in
- 0:12
between in computer science this is
- 0:14
called inbetweening or a tween animation
- 0:16
imagine we have an element that we want
- 0:18
to fade in over a duration of one second
- 0:20
when the animation starts the browser
- 0:22
calculates a new a pasty value for every
- 0:24
frame rendered and it does so using a
- 0:26
linear timing function which means the
- 0:28
amount of change that occurs to the CSS
- 0:30
value is exactly the same for each unit
- 0:32
of time but in the real physical world
- 0:34
things rarely move at a perfect linear
- 0:36
pace things ease in ease out and change
- 0:38
the velocity gracefully you can do the
- 0:40
same in your CSS animations by providing
- 0:42
a timing function there are many
- 0:44
built-in functions where you can define
- 0:46
your own custom veggie acres the easiest
- 0:48
way to create an animation with CSS is
- 0:50
with a transition start by adding the
- 0:52
transition property to a selector the
- 0:54
first value is the property that you
- 0:55
want to animate in our case its opacity
- 0:57
the second value is the duration you can
- 0:59
define it in seconds or milliseconds now
- 1:02
whenever the opacity for this element
- 1:03
changes CSS will automatically handle
- 1:05
the animation for you for example we can
- 1:08
target the hover pseudo selector and
- 1:09
change the opacity to one and that's all
- 1:11
it takes to create a fade-in fade-out
- 1:13
animation with CSS we can refine this
- 1:15
animation by adding an additional value
- 1:17
for a delay or a timing function use a
- 1:20
built-in easing function or create your
- 1:21
own custom as the a curve but what if
- 1:24
you want to animate something forever or
- 1:25
in multiple steps keyframes allow you to
- 1:28
define animations independent of a
- 1:29
selector first give your keyframe
- 1:31
animation a name then define your
- 1:32
starting styles with from and your
- 1:34
ending styles with to any intermediate
- 1:36
styles or steps in the animation can be
- 1:38
defined as a percentage in relative time
- 1:40
to the starting point if your animation
- 1:42
is 4 seconds long then 25% would be 1
- 1:44
second into that animation you can use
- 1:46
this animation by referencing it as the
- 1:48
animation name in one of your selectors
- 1:50
give it a duration and timing function
- 1:52
then change the iteration count to
- 1:53
infinite to make it loop forever this
- 1:55
has been CSS animation in 100 seconds
- 1:57
hit the like button if you want to see
- 1:59
more short videos like this thanks for


