CSS transition-timing-function Property
Example
div {
width: 100px;
background: red;
transition: width 2s;
transition-timing-function: ease-in-out;
}
div:hover {
width: 500px;
}
Hover me!
Meaning
The transition-timing-function property sets how intermediate values are calculated for CSS properties being affected by a transition effect.
Default value: | ease |
Inherited: | No |
Animatable: | No |
Version: | CSS3 |
JavaScript syntax: |
|
Standard Syntax
transition-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|revert|revert-layer|unset;
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Status
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
linear | Equivalent to cubic-bezier(0,0,1,1). Specifies a transition effect with the same speed from start to end. |
ease | This is default value. Equivalent to cubic-bezier(0.25,0.1,0.25,1). Specifies a transition effect with a slow start, then fast, then end slowly. |
ease-in | Equivalent to cubic-bezier(0.42,0,1,1). Specifies a transition effect with a slow start. |
ease-out | Equivalent to cubic-bezier(0,0,0.58,1). Specifies a transition effect with a slow end. |
ease-in-out | Equivalent to cubic-bezier(0.42,0,0.58,1). Specifies a transition effect with a slow start and end. |
step-start | Equivalent to steps(1, start). |
step-end | Equivalent to steps(1, end). |
steps(int,start|end) | Displays the transition along n stops along the transition, displaying each stop for equal lengths of time. |
cubic-bezier(n,n,n,n) | Sets values in the cubic-bezier function. Possible values are numeric values from 0 to 1 |
initial | Sets this property to its default value. |
inherit | If specified, the associated element takes the computed value of its parent element animation-delay property. |
revert | Reverts the cascaded value of the property from its current value to the value the property |
revert-layer | Rollback styles to the ones specified in previous cascade layers. |
unset | Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not. |
Default CSS Property Values
selectors {
transition-timing-function: ease;
}
More Examples
The following example show how to set all transition properties using shorthand property:
Example
div {
width: 100px;
height: 100px;
background: red;
transition: width 2s ease-in-out 2s;
}
- transition-property: width
- transition-duration: 2s
- transition-timing-function: ease-in-out
- transition-delay: 2s
The following element combines transitions for: border, width, height, background-color, transform. Hover over the red div element to see these properties animated.
Hover me!
Example
div {
border: 1px solid;
width: 100px;
height: 100px;
background-color: red;
transition: border 5s, width 2s, height 2s, background-color 2s, transform 2s;
}
div:hover {
border: 10px solid;
background-color: #0069FF;
width: 200px;
height: 200px;
transform: rotate(180deg);
}