Thuộc tính chuyển đổi kiểu
Ví dụ
Di chuột qua phần tử div để thay đổi dần diện mạo của nó:
document.getElementById("myDIV").style.transition = "all 2s";
Hãy tự mình thử »Sự miêu tả
Thuộc tính transition là thuộc tính viết tắt của bốn thuộc tính transition:
transitionProperty, transitionDuration, transitionTimingFunction và transitionDelay.
Lưu ý: Luôn chỉ định thuộc tính transitionDuration, nếu không thời lượng bằng 0 và quá trình chuyển đổi sẽ không có hiệu lực.
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.
Property | |||||
---|---|---|---|---|---|
transition | 26.0 | 10.0 | 16.0 | 6.1 | 12.1 |
Cú pháp
Trả về thuộc tính chuyển tiếp:
object .style.transition
Đặt thuộc tính chuyển tiếp:
object .style.transition = "property duration timing-function delay |initial|inherit"
Giá trị tài sản
Value | Description |
---|---|
transitionProperty | Specifies the name of the CSS property the transition effect is for |
transitionDuration | Specifies how many seconds or milliseconds the transition effect takes to complete |
transitionTimingFunction | Specifies the speed curve of the transition effect |
transitionDelay | Defines when the transition effect will start |
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: | tất cả 0 dễ dàng 0 |
---|---|
Giá trị trả về: | Một Chuỗi, biểu diễn thuộc tính chuyển tiếp của một phần tử |
Phiên bản CSS | CSS3 |
Trang liên quan
Tham chiếu CSS: thuộc tính chuyển tiếp