Tillitsdone
down Scroll to discover
CSS transition-timing-function Enhance Web Animations
CSS transition-timing-function controls the speed of CSS transitions.

It offers predefined keywords like 'ease', 'linear', 'ease-in', 'ease-out', and custom cubic Bézier curves and step functions.
thumbnail
/* Keyword Values */
.ease {
transition-timing-function: ease;
}
.linear {
transition-timing-function: linear;
}
.ease-in {
transition-timing-function: ease-in;
}
.ease-out {
transition-timing-function: ease-out;
}
.ease-in-out {
transition-timing-function: ease-in-out;
}
/* Step Functions */
.step-start {
transition-timing-function: step-start;
}
.step-end {
transition-timing-function: step-end;
}
.steps-4-jump-end {
transition-timing-function: steps(4, jump-end);
}
/* Cubic Bézier Curve */
.custom-bezier {
transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1.0);
}
/* Multiple Easing Functions */
.multiple-easing {
transition-timing-function: ease, step-start, cubic-bezier(0.1, 0.7, 0.1, 1.0);
}
/* Accessibility Considerations */
@media (prefers-reduced-motion: reduce) {
.element {
transition-property: none;
}
}
/* Example Comparison */
.element {
transition-property: all;
transition-duration: 2s;
}
.ease:hover {
transition-timing-function: ease;
}
.linear:hover {
transition-timing-function: linear;
}
.ease-in:hover {
transition-timing-function: ease-in;
}
.ease-out:hover {
transition-timing-function: ease-out;
}
.ease-in-out:hover {
transition-timing-function: ease-in-out;
}
.step-start:hover {
transition-timing-function: step-start;
}
.step-end:hover {
transition-timing-function: step-end;
}
.steps-4-jump-end:hover {
transition-timing-function: steps(4, jump-end);
}
.custom-bezier:hover {
transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1.0);
}
.multiple-easing:hover {
transition-timing-function: ease, step-start, cubic-bezier(0.1, 0.7, 0.1, 1.0);
}
/* Practical Examples */
.parent {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.parent > div[class] {
width: 12em;
min-width: 12em;
height: 3em;
margin-bottom: 4px;
background-color: black;
border: 1px solid red;
color: white;
transition-property: all;
transition-duration: 7s;
}
.parent > div.box1 {
width: 90vw;
min-width: 24em;
background-color: magenta;
color: yellow;
border: 1px solid orange;
transition-property: all;
transition-duration: 2s;
}
.jump-start {
transition-timing-function: steps(5, jump-start);
}
.jump-end {
transition-timing-function: steps(5, jump-end);
}
.jump-both {
transition-timing-function: steps(5, jump-both);
}
.jump-none {
transition-timing-function: steps(5, jump-none);
}
.step-start {
transition-timing-function: step-start;
}
.step-end {
transition-timing-function: step-end;
}
.ease {
transition-timing-function: ease;
}
.easein {
transition-timing-function: ease-in;
}
.easeout {
transition-timing-function: ease-out;
}
.easeinout {
transition-timing-function: ease-in-out;
}
.linear {
transition-timing-function: linear;
}
.cb {
transition-timing-function: cubic-bezier(0.2, -2, 0.8, 2);
}
/* Custom Step Function */
.jump-start {
transition-timing-function: steps(5, jump-start);
}
.jump-end {
transition-timing-function: steps(5, jump-end);
}
.jump-both {
transition-timing-function: steps(5, jump-both);
}
.jump-none {
transition-timing-function: steps(5, jump-none);
}
/* Comparing Different Step Functions */
.step1 {
transition-timing-function: steps(5, jump-start);
}
.step2 {
transition-timing-function: steps(5, jump-end);
}
.step3 {
transition-timing-function: steps(5, jump-both);
}
/* Basic Cubic Bézier Curve */
.custom-bezier {
width: 100px;
height: 100px;
background-color: green;
transition-property: width, height, background-color;
transition-duration: 2s;
transition-timing-function: cubic-bezier(0.2, -2, 0.8, 2);
color: white;
display: flex;
justify-content: center;
align-items: center;
}
.custom-bezier:hover {
width: 300px;
height: 300px;
background-color: yellow;
}
/* Comparing Different Cubic Bézier Curves */
.bezier1 {
background-color: blue;
transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1.0);
}
.bezier2 {
background-color: green;
transition-timing-function: cubic-bezier(0.2, -2, 0.8, 2);
}
.bezier3 {
background-color: purple;
transition-timing-function: cubic-bezier(0.42, 0, 1.0, 1.0);
}
.bezier-example {
width: 100px;
height: 100px;
background-color: blue;
transition-property: width, height, background-color;
transition-duration: 2s;
transition-timing-function: cubic-bezier(0.1, 0.7, 0.1, 1.0);
color: white;
display: flex;
justify-content: center;
align-items: center;
}
.bezier-example:hover {
width: 300px;
height: 300px;
background-color: red;
}

Formal Definition

The transition-timing-function property in CSS is defined by the CSS Transitions specification. This property allows developers to control the acceleration curve of a transition, determining how the values of CSS properties change over time. The formal definition provides detailed information about the initial value, applicability, inheritance, computed value, and animation type of the transition-timing-function property.

Initial Value

  • Initial Value: ease
    • The default timing function is ease, which provides a smooth transition that starts slowly, accelerates in the middle, and then slows down towards the end.

Applicability

  • Applies to: All elements, including ::before and ::after pseudo-elements.
    • The transition-timing-function property can be applied to any HTML element and its pseudo-elements, allowing for transitions on a wide range of CSS properties.

Inheritance

  • Inherited: No
    • The transition-timing-function property is not inherited from the parent element. Each element must have its own timing function defined, unless it is explicitly set to inherit the value from its parent using the inherit keyword.

Computed Value

  • Computed Value: As specified
    • The computed value of the transition-timing-function property is the same as the specified value. This means that the browser will use the exact timing function defined in the CSS.

Animation Type

  • Animation Type: Not animatable
    • The transition-timing-function property itself is not animatable. It defines how other CSS properties transition over time but cannot be animated or transitioned itself.

Formal Syntax

The transition-timing-function property in CSS has a well-defined syntax that outlines how developers can specify the timing functions for transitions. Understanding the formal syntax helps ensure that the property is used correctly and effectively.

Syntax Structure

The syntax for the transition-timing-function property is as follows:

transition-timing-function: <easing-function> [ , <easing-function> ]* | initial | inherit;

Breakdown of Syntax Components

  1. <easing-function>:
    • This represents the easing function to be applied to the transition. It can be one of the following types:
      • Linear Easing Function: linear
      • Cubic Bézier Easing Function: cubic-bezier(p1, p2, p3, p4)
      • Step Easing Function: steps(n, <jumpterm>)
      • Predefined Keywords: ease, ease-in, ease-out, ease-in-out, step-start, step-end
  2. initial:
    • Sets the property to its default value, which is ease.
  3. inherit:
    • Inherits the value from the parent element.

Linear Easing Function

  • Syntax:
    linear
  • Description:
    • The linear easing function provides a transition effect that progresses at a constant speed from start to finish.

Cubic Bézier Easing Function

  • Syntax:
    cubic-bezier(p1, p2, p3, p4)
  • Description:
    • The cubic-bezier function allows developers to define their own cubic Bézier curve, which specifies the speed and acceleration of the transition. The parameters p1, p2, p3, and p4 define the control points of the curve.
    • Constraints: The values of p1 and p3 must be between 0 and 1.

Step Easing Function

  • Syntax:
    steps(n, <jumpterm>)
  • Description:
    • The steps function divides the transition into a specified number of equal intervals, creating a jump effect at each interval.
    • Parameters:
      • n: The number of intervals in the transition. Must be a positive integer.
      • <jumpterm>: Specifies the position of the jump within each interval. Possible values are:
        • jump-start: The transition jumps to the next value at the start of each interval.
        • jump-end: The transition jumps to the next value at the end of each interval.
        • jump-none: The transition does not jump at the start or end of each interval; instead, it holds at both the 0% mark and the 100% mark for 1/n of the duration.
        • jump-both: The transition includes pauses at both the 0% and 100% marks.
        • start: Same as jump-start.
        • end: Same as jump-end.

Predefined Keywords

  • Syntax:
    ease | ease-in | ease-out | ease-in-out | step-start | step-end
  • Description:
    • These keywords represent predefined easing functions that cover common transition patterns.
    • Equivalents:
      • ease: Equivalent to cubic-bezier(0.25, 0.1, 0.25, 1.0)
      • linear: Equivalent to cubic-bezier(0.0, 0.0, 1.0, 1.0)
      • ease-in: Equivalent to cubic-bezier(0.42, 0, 1.0, 1.0)
      • ease-out: Equivalent to cubic-bezier(0, 0, 0.58, 1.0)
      • ease-in-out: Equivalent to cubic-bezier(0.42, 0, 0.58, 1.0)
      • step-start: Equivalent to steps(1, jump-start)
      • step-end: Equivalent to steps(1, jump-end)

Example Usage

Here is an example of how to use the transition-timing-function property with different easing functions:

.element {
transition-property: all;
transition-duration: 2s;
transition-timing-function: ease, linear, cubic-bezier(0.1, 0.7, 0.1, 1.0), steps(5, jump-end);
}

In this example:

  • The transition-property specifies that all properties will transition.
  • The transition-duration specifies that the transition will last for 2 seconds.
  • The transition-timing-function specifies multiple easing functions: ease, linear, cubic-bezier(0.1, 0.7, 0.1, 1.0), and steps(5, jump-end). Each function will be applied to the corresponding property in the order defined by the transition-property.

Conclusion

Understanding the formal syntax of the transition-timing-function property is essential for effectively using transitions in CSS. By adhering to the syntax structure and utilizing the various easing functions, developers can create smooth and dynamic animations that enhance the visual appeal and interactivity of their web projects.

For the most up-to-date information, refer to the official CSS Transitions specification and browser documentation. This will help you make informed decisions about implementing transitions in your web projects.

See Also

To further enhance your knowledge and skills in CSS transitions and animations, consider exploring the following related topics and resources:

Related CSS Properties

  • [transition]WebsiteUrl: A shorthand property that combines transition-property, transition-duration, transition-timing-function, and transition-delay.
  • [transition-property]WebsiteUrl: Specifies the CSS properties to which the transition should be applied.
  • [transition-duration]WebsiteUrl: Defines the duration over which the transition should occur.
  • [transition-delay]WebsiteUrl: Specifies the delay before the transition starts.
  • [transition-property]WebsiteUrl: Lists the properties to be transitioned.

CSS Animations

  • [@keyframes]WebsiteUrl: Defines the animation sequence using keyframes.
  • [animation]WebsiteUrl: A shorthand property for defining animations, combining animation-name, animation-duration, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, animation-fill-mode, and animation-play-state.
  • [animation-name]WebsiteUrl: Specifies the name of the animation to be applied.
  • [animation-duration]WebsiteUrl: Defines the duration of the animation.
  • [animation-timing-function]WebsiteUrl: Specifies the speed curve of the animation.
  • [animation-delay]WebsiteUrl: Specifies the delay before the animation starts.
  • [animation-iteration-count]WebsiteUrl: Defines the number of times the animation should repeat.
  • [animation-direction]WebsiteUrl: Specifies the direction of the animation.
  • [animation-fill-mode]WebsiteUrl: Defines how the animation should apply styles before and after it executes.
  • [animation-play-state]WebsiteUrl: Specifies whether the animation is running or paused.

Related Resources

  • MDN Web Docs: Comprehensive documentation on CSS properties and animations.
    • [MDN CSS Transitions]WebsiteUrl
    • [MDN CSS Animations]WebsiteUrl
  • W3C Specifications: Official specifications for CSS transitions and animations.
    • [CSS Transitions Level 1]WebsiteUrl
    • [CSS Animations Level 1]WebsiteUrl
  • Can I Use: A website that provides compatibility tables for support of CSS properties across different browsers.
    • [Can I use CSS Transitions]WebsiteUrl
    • [Can I use CSS Animations]WebsiteUrl

Tutorials and Guides

  • CSS-Tricks: A collection of articles and tutorials on CSS transitions and animations.
    • [A Complete Guide to CSS Transitions]WebsiteUrl
    • [A Complete Guide to CSS Animations]WebsiteUrl
  • Smashing Magazine: In-depth articles and tutorials on CSS transitions and animations.
    • [CSS Transitions and Animations: An Overview]WebsiteUrl

Books

  • CSS in Depth by Keith J. Grant: A comprehensive guide to CSS, including advanced topics like transitions and animations.
  • CSS Animations and Transitions for the Modern Web by Richard Clark: A practical guide to creating modern web animations using CSS.

Online Courses

  • FreeCodeCamp: Offers free courses on CSS transitions and animations.
    • [CSS Transitions and Animations]WebsiteUrl
  • Udemy: Paid courses on CSS transitions and animations.
    • [CSS Animations and Transitions]WebsiteUrl

Conclusion

Exploring these related topics and resources will help you deepen your understanding of CSS transitions and animations. By learning about related CSS properties, official specifications, tutorials, and guides, you can enhance your skills and create more dynamic and engaging web designs.

Whether you are a beginner or an experienced web developer, these resources will provide valuable insights and practical tips to help you master CSS transitions and animations.

Get in Touch
Thank you for your interest in Tillitsdone! Whether you have a question about our services, want to discuss a potential project, or simply want to say hello, we're here and ready to assist you.
We'll be right here with you every step of the way.
Contact Information
rick@tillitsdone.com+66824564755
Find All the Ways to Get in Touch with Tillitsdone - We're Just a Click, Call, or Message Away. We'll Be Right Here, Ready to Respond and Start a Conversation About Your Needs.
Address
9 Phahonyothin Rd, Khlong Nueng, Khlong Luang District, Pathum Thani, Bangkok Thailand
Visit Tillitsdone at Our Physical Location - We'd Love to Welcome You to Our Creative Space. We'll Be Right Here, Ready to Show You Around and Discuss Your Ideas in Person.
Social media
Connect with Tillitsdone on Various Social Platforms - Stay Updated and Engage with Our Latest Projects and Insights. We'll Be Right Here, Sharing Our Journey and Ready to Interact with You.
We anticipate your communication and look forward to discussing how we can contribute to your business's success.
We'll be here, prepared to commence this promising collaboration.
Frequently Asked Questions
Explore frequently asked questions about our products and services.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.