Animation exercises Flashcards
Given the following CSS rule, identify the name, duration, and iteration count of the animation
div { animation: spin 3s infinite; }
animation-name: spin
animation-duration: 3s
animation-iteration-count: infinite
Write a CSS rule to apply an animation named spin, which lasts for 2s, runs infinite times, and has a linear timing function.
div { animation: spin 2s linear infinite; }
What will be the behavior of the following CSS animation?
div { animation: bounce 2s ease-in-out 1s infinite alternate both paused; }
This animation:
- is named
bounce
- lasts
2s
- has an
ease-in-out
timing function, meaning it starts slowly, accelerates in the middle, and then slows down at the end - waits
1s
before starting the animation - runs an
infinite
number of times - alternates directions between iterations (
alternate
) - applies styles from the animation to the element
both
before (backwards
) and after (forwards
) the animation’s execution - is initially
paused
, meaning it will not run until itsplay-state
is changed to running
Write a CSS rule for an animation named slide
, which lasts for 5s
, has a delay of 2s
, runs 3 times, and is initially paused
div { animation: slide 5s 2s 3 paused; }
Given the following CSS rule, how many times will the animation run and in what direction?
div { animation: growShrink 4s infinite reverse; }
-
animation-iteration-count: infinite
, so the animation will run indefinitely -
animation-direction: reverse
, so the animation will play in reverse
What will be the animation-fill-mode
and animation-play-state
for the following CSS rule?
div { animation: popIn 3s both running; }
-
animation-fill-mode: both
, meaning the styles are applied to the element for both the state before and after the animation’s execution -
animation-play-state: running
, meaning the animation will run as soon as it is applied
Given the following CSS rule, what will be the name and duration of the animation?
div { animation: popOut 5s; }
-
animation-name
: popOut -
animation-duration
: 5s
Write a CSS rule to apply an animation named rotate
, which lasts for 1s
, runs 5
times, and has an ease-out
timing function.
div { animation: rotate 1s ease-out 5; }
What is the behavior of the following CSS animation?
div { animation: bounce 2s ease-in 1s 3 alternate backwards; }
- is named
bounce
- lasts
2s
- has an
ease-in
timing function, meaning it starts slowly and then accelerates - waits
1s
before starting the animation - runs
3
times - alternates directions between iterations (
alternate
) - applies styles from the animation to the element before the animation’s execution (
backwards
)
Write a CSS rule for an animation named fade
, which lasts for 3s
, has a delay of 1s
, runs 2
times, and uses a ease-in-out
timing function.
div { animation: fade 3s ease-in-out 1s 2; }
What will be the animation-timing-function
and animation-delay
for the following CSS rule?
div { animation: grow 3s ease-in 1s; }
-
animation-timing-function: ease-in
, meaning the animation starts slowly and then accelerates -
animation-delay: 1s
, meaning the animation will start after a delay of 1 second
Given the following CSS rule, what is the direction of the animation and its play state?
div { animation: shrink 4s alternate paused; }
-
animation-direction: alternate
, meaning the animation will alternate directions with each iteration -
animation-play-state: paused
, meaning the animation will not start running until its play state is changed
Write a CSS rule to apply an animation named jump
, which lasts for 1.5s
, has a delay of 0.5s
, runs infinite
times, and is initially running
.
div { animation: jump 1.5s 0.5s infinite running; }
What will be the animation-iteration-count
and animation-fill-mode
for the following CSS rule?
div { animation: slideIn 3s 1 backwards; }
-
animation-iteration-count: 1
, meaning the animation will play once -
animation-fill-mode: backwards
, meaning the styles defined by the animation’s first keyframe will be applied as soon as the animation is applied to the element
Given the following CSS rule, what will be the name, duration, and timing function of the animation?
div { animation: flip 2s cubic-bezier(0.1, 0.7, 1.0, 0.1) 1s; }
animation-name: flip
animation-duration: 2s
-
animation-timing-function: cubic-bezier(0.1, 0.7, 1.0, 0.1)
, this represents a cubic bezier curve for customizing the timing function