
- CSS - Home
- CSS - Roadmap
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Types
- CSS - Measurement Units
- CSS - Selectors
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS - Cascading
- CSS - Universal Selectors
- CSS - ID Selectors
- CSS - Group Selectors
- CSS - Class Selectors
- CSS - Child Selectors
- CSS - Element Selectors
- CSS - Descendant Selectors
- CSS - General Sibling Selectors
- CSS - Adjacent Sibling Selectors
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Advanced Features
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS Interview Questions
- CSS Online Quiz
- CSS Online Test
- CSS Mock Test
- CSS - Quick Guide
- CSS - Cheatsheet
- CSS - Properties References
- CSS - Functions References
- CSS - Color References
- CSS - Web Browser References
- CSS - Web Safe Fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - animation-timing-function Property
CSS animation-timing-function property determines the speed curve of an animation which determines the time taken by an animation to make transition from one set of CSS styles to another set of CSS styles. It determines 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 Values
Values | Description |
---|---|
linear | The animation has the same speed from start to end. |
ease | The animation starts slowly, then speeds up and then slows down again. Default. |
ease-in | The animation starts slowly and then speeds up. |
ease-out | The animation plays normaly but slows down at the end. |
ease-in-out | The animation starts slowly, then speeds up and then slows down again. |
step-start | The animation jumps directly to the end state at the start of the keyframe animation. |
step-end | The animation jumps to the end state at the end of the keyframe animation. |
steps(int,start|end) | It specifies a stepping function with the number of steps alogn with the position of the start or end (e.g., steps(6, end)). |
cubic-bezier(n,n,n,n) | It defines a custom timing function using a cubic-bezier curve (e.g., cubic-bezier(0.25, 0.1, 0.25, 1.0)). Possible values are from 0 to 1. |
initial | It sets the property to its default value. |
inherit | It inherits the property from its parent element. |
Examples of CSS Animation Timing Function Property
The following examples explain the animation-timing-function property using different values and functions.
Setting Same Speed of Animation Throughout
To let an animation have same speed from the start of the animation till the end, we use the linear value. In the following example, linear value has been used for the animation-timing-function property.
Example
<!DOCTYPE html> <html> <head> <style> h3 { width: 200px; text-align: center; animation-name: text; animation-duration: 4s; animation-iteration-count: infinite; border: 2px solid black; } #linear { animation-timing-function: linear; } @keyframes text { from { margin-left: 35%; } to { margin-left: 0%; } } </style> </head> <body> <h2>CSS animation-timing-function property </h2> <h3 id="linear">Linear value</h3> </body> </html>
Setting Slow Start and End to an Animation
To let an animation start slowly then take some speed and then slow down again, we use the ease value. In the following example, ease value has been used for the animation-timing-function property.
Example
<!DOCTYPE html> <html> <head> <style> h3 { width: 200px; text-align: center; animation-name: text; animation-duration: 4s; animation-iteration-count: infinite; border: 2px solid black; } #linear { animation-timing-function: ease; } @keyframes text { from { margin-left: 35%; } to { margin-left: 0%; } } </style> </head> <body> <h2>CSS animation-timing-function property </h2> <h3 id="linear">Ease value</h3> </body> </html>
Setting Slow Start to an Animation
To let an animation start slowly and then speed up, we use the ease-in value. In the following example, ease-in value has been used for the animation-timing-function property.
Example
<!DOCTYPE html> <html> <head> <style> h3 { width: 200px; text-align: center; animation-name: text; animation-duration: 4s; animation-iteration-count: infinite; border: 2px solid black; } #linear { animation-timing-function: ease-in; } @keyframes text { from { margin-left: 35%; } to { margin-left: 0%; } } </style> </head> <body> <h2>CSS animation-timing-function property </h2> <h3 id="linear">Ease-in value</h3> </body> </html>
Setting Slow End to an Animation
To let an animation play at normal pace but slow down at the end, we use the ease-out value. In the following example, ease-out value has been used for the animation-timing-function property.
Example
<!DOCTYPE html> <html> <head> <style> h3 { width: 200px; text-align: center; animation-name: text; animation-duration: 4s; animation-iteration-count: infinite; border: 2px solid black; } #linear { animation-timing-function: ease-out; } @keyframes text { from { margin-left: 35%; } to { margin-left: 0%; } } </style> </head> <body> <h2>CSS animation-timing-function property </h2> <h3 id="linear">Ease-out value</h3> </body> </html>
Setting Slow Start and End to an Animation
To let an animation start slowly, then pick some pace and then slow down towards the end, we can also use the combination of ease-in and ease-out valuees which is the ease-in-out value. In the following example, ease-in-out value has been used for the animation-timing-function property.
Example
<!DOCTYPE html> <html> <head> <style> h3 { width: 200px; text-align: center; animation-name: text; animation-duration: 4s; animation-iteration-count: infinite; border: 2px solid black; } #linear { animation-timing-function: ease-in-out; } @keyframes text { from { margin-left: 35%; } to { margin-left: 0%; } } </style> </head> <body> <h2>CSS animation-timing-function property </h2> <h3 id="linear">Ease-in-out value</h3> </body> </html>
Setting Abrupt Jump through Start
To let an animation directly reach the end state at the start of the animation's keyframe resulting in abrupt change, we use the step-start value. In the following example, step-start value has been used for the animation-timing-function property.
Example
<!DOCTYPE html> <html> <head> <style> .box { width: 100px; height: 50px; border: 2px solid black; display: flex; justify-content: center; animation: move 6s infinite; } .step-start { animation-timing-function: step-start; } @keyframes move { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(250px); } } </style> </head> <body> <h2>CSS animation-timing-function property</h2> <div class="box step-start">Step-start</div> </body> </html>
Setting Abrupt Jump through End
To let an animation directly reach the end state at the end of the animation's keyframe resulting in abrupt change, we use the step-end value. In the following example, step-end value has been used for the animation-timing-function property.
Example
<!DOCTYPE html> <html> <head> <style> .box { width: 100px; height: 50px; border: 2px solid black; display: flex; justify-content: center; animation: move 6s infinite; } .step-start { animation-timing-function: step-end; } @keyframes move { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(250px); } } </style> </head> <body> <h2>CSS animation-timing-function property</h2> <div class="box step-start">Step-end</div> </body> </html>
Setting Stepped Animation
To let an animation move in step intervals, we use the steps() function. It takes in two parameters, the first, an integer and the second either 'start' or 'end' specifying the point at which the change of values occur within the interval. In the following example, the integer is 4 and second parameter is start.
Example
<!DOCTYPE html> <html> <head> <style> .box { width: 100px; height: 50px; border: 2px solid black; display: flex; justify-content: center; animation: move 6s infinite; } .step-start { animation-timing-function: steps(4,start); } @keyframes move { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(250px); } } </style> </head> <body> <h2>CSS animation-timing-function property</h2> <div class="box step-start">Steps(4,start)</div> </body> </html>
Setting Variable Speed Animation
To let the animation progress with variable speed, we use the custom-beizer() function. This function represent a cubic bezier curve which is defined by four pointsP0,P1,P2,P3: P0 (start) and P3 (end). In the following example, 0.1,0.7,1.0 and 0.1 values have been used in the function.
Example
<!DOCTYPE html> <html> <head> <style> .box { width: 100px; height: 50px; border: 2px solid black; display: flex; justify-content: center; align-items: center; animation: move 6s infinite; } .cubic { animation-timing-function: cubic-bezier(0.1, 0.7, 1.0, 0.1); } @keyframes move { 0%,100% { transform: translateX(0); } 50% { transform: translateX(250px); } } </style> </head> <body> <h2>CSS animation-timing-function property</h2> <div class="box cubic">Cubic Beizer</div> </body> </html>
Supported Browsers
Property | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
animation-timing-function | 43.0 | 10.0 | 16.0 | 9.0 | 30.0 |