Phong cách hoạt hình Thuộc tính
Ví dụ
Thay đổi hoạt ảnh của phần tử <div>, sử dụng thuộc tính tốc ký:
document.getElementById("myDIV").style.animation = "mynewmove 4s 2";
Hãy tự mình thử »Sự miêu tả
Thuộc tính hoạt hình là thuộc tính viết tắt của sáu thuộc tính hoạt hình:
tên hoạt hình
Thời lượng hoạt ảnh
hoạt hìnhChức năng thời gian
hoạt hìnhDelay
hoạt hìnhIterationCount
hoạt hìnhHướng
Lưu ý: Luôn chỉ định thuộc tính animationDuration, nếu không thời lượng bằng 0 và sẽ không bao giờ được phát.
Cú pháp
Trả về thuộc tính hoạt ảnh:
object .style.animation
Đặt thuộc tính hoạt ảnh:
object .style.animation = "name duration timingFunction delay iterationCount direction fillMode playState "
Giá trị tài sản
Value | Description |
---|---|
animationName | Specifies the name of the keyframe you want to bind to the selector |
animationDuration | Specifies how many seconds or milliseconds an animation takes to complete |
animationTimingFunction | Specifies the speed curve of the animation |
animationDelay | Specifies a delay before the animation will start |
animationIterationCount | Specifies how many times an animation should be played |
animationDirection | Specifies whether or not the animation should play in reverse on alternate cycles |
animationFillMode | Specifies what values are applied by the animation outside the time it is executing |
animationPlayState | Specifies whether the animation is running or paused |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Chi tiết kỹ thuật
Giá trị mặc định: | không 0 dễ dàng 0 1 bình thường không chạy |
---|---|
Giá trị trả về: | Một Chuỗi, biểu diễn thuộc tính hoạt hình của một phần tử |
Phiên bản CSS | CSS3 |
Hỗ trợ trình duyệt
animation
là một tính năng CSS3 (1999).
Nó được hỗ trợ đầy đủ trong tất cả các trình duyệt:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 11 |
Trang liên quan
Tham chiếu CSS: thuộc tính hoạt ảnh