The Wayback Machine - https://web.archive.org/web/20240706201807/https://www.geeksforgeeks.org/css-animation-timing-function-property/
Open In App

CSS animation-timing-function Property

Last Updated : 04 Jul, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The animation-timing-function property in CSS is used to specify how an animation makes transitions through keyframes. It defines the speed curve of the animation, determining how the intermediate keyframes are calculated and the pacing of the animation.

Syntax:

animation-timing-function: linear | ease | ease-in | ease-out | ease-in-out | step-start | step-end | steps(int, start | end) | cubic-bezier(n, n, n, n) | initial | inherit;

Property Value

ValueDescription
easeThe animation starts slowly, speeds up, and then slows down (default).
linearThe animation maintains the same speed from start to end.
ease-inThe animation begins slowly and then speeds up.
ease-outThe animation plays at normal speed but slows down at the end.
ease-in-outThe animation starts slowly, speeds up, and then slows down again.
step-startThe animation jumps immediately to the end state at the start of the keyframe animation.
step-endThe animation jumps to the end state at the end of the keyframe animation.
steps()Specifies a stepping function with the number of steps and the position of the start or end (e.g., steps(4, end)).
cubic-bezier()Defines a custom timing function using a cubic-bezier curve (e.g., cubic-bezier(0.25, 0.1, 0.25, 1.0)).
initialSets the property to its default value.
inheritInherits the property from its parent element.

Example: HTML Program to illustrate the above property values for the animation-timing-function property.

HTML
<!DOCTYPE html>
<html>
  
<head>
    <title>
        CSS | animation-timing-function Property
    </title>
    <style>
        .geeks {
            font-size: 40px;
            text-align: center;
            font-weight: bold;
            color: #090;
            padding-bottom: 5px;
            font-family: Times New Roman;
        }

        .geeks1 {
            font-size: 17px;
            font-weight: bold;
            text-align: center;
            font-family: Times New Roman;
        }

        h2 {
            width: 350px;
            animation-name: text;
            animation-duration: 4s;
            animation-iteration-count: infinite;
            background-color: rgb(255, 210, 85);
        }

        #one {
            animation-timing-function: ease;
        }

        #two {
            animation-timing-function: linear;
        }

        #three {
            animation-timing-function: ease-in;
        }

        #four {
            animation-timing-function: ease-out;
        }

        #five {
            animation-timing-function: ease-in-out;
        }

        @keyframes text {
            from {
                margin-left: 60%;
            }

            to {
                margin-left: 0%;
            }
        }
    </style>
</head>

<body>
    <div class="geeks">
        GeeksforGeeks
    </div>
    <div class="geeks1">
        A computer science portal for geeks
    </div>
    <!-- For this the animation-timing-function will 
             be set to ease -->
    <h2 id="one">
        This text is ease.
    </h2>
    <!-- For this animation-timing-function will 
             be set to linear -->
    <h2 id="two">
        This text is linear.
    </h2>
    <!-- For this animation-timing-function will 
             be set to ease-in -->
    <h2 id="three">
        This text is ease-in.
    </h2>
    <!-- For this animation-timing-function will 
             be set to ease-out -->
    <h2 id="four">
        This text is ease-out.
    </h2>
    <!-- For this animation-timing-function will 
             be set to ease-in-out -->
    <h2 id="five">
        This text is ease-in-out.
    </h2>
</body>
  
</html>

Output:

The animation-timing-function property in CSS is essential for defining the pacing and speed curve of animations. By understanding and using different timing functions, you can create smooth and engaging animations for your web projects

Supported Browser: The browser supported by animation-timing-function property are listed below:

  • Google Chrome 43.0 and above
  • Edge 12.0 and above
  • Firefox 16.0 and above
  • Opera 30.0 and above
  • Safari 9.0 and above


Previous Article
Next Article

Similar Reads

CSS transition-timing-function Property
The transition-timing-function property specifies the speed curve of the transition effect. It determines how CSS properties change values over time during transitions. This curve, or easing function, defines the rate of change, influencing the smoothness and perception of animation transitions on web elements. Syntaxanimation-timing-function: &lt;
2 min read
Tailwind CSS Transition Timing Function
This class accepts lots of value in tailwind CSS in which all the properties are covered in class form. The transition timing function class is used to specify the time an animation uses to change from one set of CSS transitions to another. In CSS, we have done that by using the CSS transition-timing-function. Transition timing function classes: ea
2 min read
HTTP headers | Server-Timing
The HTTP Server-Timing header is a response-type header. This header is used to communicate between two or more metrics and descriptions for a given request-response cycle from the user agent. The HTTP Server-Timing header is useful to any back-end server timing metrics like read or write in any databases, accessing files, etc. It can be used in th
2 min read
What are the various timing features of Node.js ?
The timer modules in Node.js consists of functions that help to control the timings of code execution. It includes setTimeout(), setImmediate(), and setInterval() methods. 1. setTimeout() Method: The setTimeout() method is used to schedule code execution after a designated amount of milliseconds. The specified function will be executed once. We can
3 min read
HTTP headers | Timing-Allow-Origin
The Timing-Allow-Origin(TAO) header is a response-type header. It is used to indicate all the origins that are permitted to read the values of attributes retrieved from the Resource Timing API’s features. The default values assigned to these attributes is “zero” as a consequence of cross-origin restrictions. The TAO header can be a wildcard (*) tha
2 min read
Timing Events in Javascript
Timing events are the events that help to execute a piece of code at a specific time interval. These events are directly available in the HTML DOM (Document Object Model) Window object, i.e., they are present in the browser. So, these are called global methods and can be invoked through the 'window' object or without it. The various timing events a
5 min read
CSS Animation and @Keyframes Property
CSS allows the animation of HTML elements without using JavaScript. An animation lets an element systematically and with proper timing, change from one style to another. You can change whatever CSS properties you want, end number of times, as you want it. To use CSS animation, you must first specify some @keyframes for the animation. @keyframes wil
4 min read
Animation using clip-path property in CSS
The clip-path CSS property is used to clip the region in such a way that element in the clipped regions are shown. In this article, we will see how we can use the clip-path and @keyframes together to create an image animation. Step 1: Create a div with a class container that should include &lt;img&gt; tag. C/C++ Code &amp;lt;!DOCTYPE html&amp;gt;
2 min read
CSS animation Property
The CSS animation property is used to specify the animation that should be applied to an element. The animation property is a shorthand for several other CSS properties that control different aspects of the animation. Syntax: animation: animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-d
2 min read
CSS animation-name Property
The animation-name property in CSS is a crucial part of defining animations. It is used to specify the name of the @keyframes that describe the animation. Understanding the Animation-Name PropertyThe animation-name property in CSS is used to connect an element to a set of keyframes. The keyframes describe the animation’s sequence of changes. Syntax
2 min read
three90RightbarBannerImg