Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Defining Animation Duration and Timing | Advanced CSS Animations
Advanced CSS Techniques

book
Defining Animation Duration and Timing

Let's consider all possible ways to work with the animation time.

animation-duration property

animation-duration sets the time required for an animation to complete one cycle (change from the initial to the final state), measured in either seconds (s) or milliseconds (ms).

css
animation-duration: 3s | 3000ms

Let's run the following example and hover the box:

html

index.html

css

index.css

copy
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<p>
Hover the area below to see the difference in the behavior of the
different time duration.
</p>
<div class="container">
<div class="box">1s</div>
<div class="box">2s</div>
<div class="box">5s</div>
</div>
</body>
</html>

animation-timing-function property

animation-timing-function determines how the animation progresses over time, controlling the acceleration and deceleration of the animation. The animation-timing-function can have the same values as the transition-timing-function property. Several predefined timing functions are available, such as linear, ease, and ease-in-out, or we can define a custom cubic bezier curve using the cubic-bezier() function.

css
animation-timing-function: time_function

Let's apply different time_functions to the boxes in the example:

html

index.html

css

index.css

copy
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<p>
Hover the area below to see the difference in the behavior of the
different time duration.
</p>
<div class="container">
<div class="box">ease</div>
<div class="box">ease-in</div>
<div class="box">ease-out</div>
</div>
</body>
</html>

animation-delay property

animation-delay sets the time that should elapse before animation starts. It can be specified in seconds (s) or milliseconds (ms).

css
animation-delay: 0.1s | 100ms

Let's apply different delays to the boxes in the example:

html

index.html

css

index.css

copy
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<p>
Hover the area below to see the difference in the behavior of the
different time duration.
</p>
<div class="container">
<div class="box">100ms</div>
<div class="box">300ms</div>
<div class="box">1000ms</div>
</div>
</body>
</html>
question mark

We can specify the time delay for the animation to start, the time during which the animation will process, and also the animation progress over the time.

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 2
some-alt