Thuộc tính chức năng định giờ hoạt ảnh CSS
Ví dụ
Phát một hình ảnh động có cùng tốc độ từ đầu đến cuối:
div {
animation-timing-function: linear;
}
Hãy tự mình thử »Thêm ví dụ "Hãy tự mình thử" bên dưới.
Định nghĩa và cách sử dụng
animation-timing-function
chỉ định đường cong tốc độ của hoạt ảnh.
Đường cong tốc độ xác định THỜI GIAN mà hoạt ảnh sử dụng để thay đổi từ bộ kiểu CSS này sang bộ kiểu CSS khác.
Đường cong tốc độ được sử dụng để thực hiện các thay đổi một cách trơn tru.
Giá trị mặc định: | xoa dịu |
---|---|
Thừa hưởng: | KHÔNG |
Hoạt hình: | KHÔNG. Đọc về hoạt hình |
Phiên bản: | CSS3 |
Cú pháp JavaScript: | đối tượng .style.animationTimingFunction="tuyến tính" Hãy thử nó |
Hỗ trợ trình duyệt
Các số trong bảng chỉ định phiên bản trình duyệt đầu tiên hỗ trợ đầy đủ thuộc tính.
Các số theo sau là -webkit-, -moz- hoặc -o- chỉ định phiên bản đầu tiên hoạt động với tiền tố.
Property | |||||
---|---|---|---|---|---|
animation-timing-function | 43.0 4.0 -webkit- |
10.0 | 16.0 5.0 -moz- |
9.0 4.0 -webkit- |
30.0 15.0 -webkit- 12.0 -o- |
Cú pháp CSS
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;
Hàm định thời gian hoạt ảnh sử dụng hàm toán học, được gọi là đường cong Cubic Bezier, để tạo đường cong tốc độ. Bạn có thể sử dụng các giá trị của riêng mình trong hàm này hoặc sử dụng một trong các giá trị được xác định trước:
Giá trị tài sản
Value | Description | Demo |
---|---|---|
linear | The animation has the same speed from start to end | Play it » |
ease | Default value. The animation has a slow start, then fast, before it ends slowly | Play it » |
ease-in | The animation has a slow start | Play it » |
ease-out | The animation has a slow end | Play it » |
ease-in-out | The animation has both a slow start and a slow end | Play it » |
step-start | Equivalent to steps(1, start) | |
step-end | Equivalent to steps(1, end) | |
steps(int,start|end) | Specifies a stepping function, with two parameters. The first parameter specifies the number of intervals in the function. It must be a positive integer (greater than 0). The second parameter, which is optional, is either the value "start" or "end", and specifies the point at which the change of values occur within the interval. If the second parameter is omitted, it is given the value "end" | |
cubic-bezier( n , n , n , n ) | Define your own values in the cubic-bezier function Possible values are numeric values from 0 to 1 |
|
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Mẹo: Hãy thử các giá trị khác nhau trong phần "Ví dụ khác" bên dưới.
Thêm ví dụ
Ví dụ
Để hiểu rõ hơn về các giá trị hàm thời gian khác nhau;
Dưới đây là năm phần tử <div> khác nhau với năm giá trị khác nhau:
#div1 {animation-timing-function: linear;}
#div2 {animation-timing-function: ease;}
#div3 {animation-timing-function: ease-in;}
#div4 {animation-timing-function: ease-out;}
#div5 {animation-timing-function: ease-in-out;}
Hãy tự mình thử »Ví dụ
Tương tự như ví dụ trên, nhưng đường cong tốc độ được xác định bằng hàm bezier bậc ba:
#div1 {animation-timing-function: cubic-bezier(0,0,1,1);}
#div2 {animation-timing-function: cubic-bezier(0.25,0.1,0.25,1);}
#div3 {animation-timing-function: cubic-bezier(0.42,0,1,1);}
#div4 {animation-timing-function: cubic-bezier(0,0,0.58,1);}
#div5 {animation-timing-function: cubic-bezier(0.42,0,0.58,1);}
Hãy tự mình thử »Trang liên quan
Hướng dẫn CSS: Hoạt hình CSS
Tham chiếu DOM HTML: thuộc tính animationTimingFunction