Kiểm tra JSFiddle đây: http://jsfiddle.net/fRzwS/373/.
Hoạt ảnh không dừng vì định nghĩa muộn của animation
ghi đè giá trị của thuộc tính animation-play-state
. Theo W3C specification, animation
:
The 'animation' shorthand property is a comma-separated list of
animation definitions, each of which combines seven of
the animation properties into a single component value.
Và số bảy thuộc tính là:
<single-animation> = <single-animation-name> || <time>
|| <single-animation-timing-function>
|| <time> || <single-animation-iteration-count> || <single-animation-direction>
|| <single-animation-fill-mode> || <single-animation-play-state>
Nó tương tự như các thuộc tính background
và background-color
.
Vì vậy, trong mã gốc:
#tech {
-webkit-animation-play-state: paused;
-webkit-animation: moveSlideshow 10s linear infinite;
}
tài sản animation-play-state
được thiết lập để được paused
. Tuy nhiên, thuộc tính muộn animation
OVERWRITES giá trị này theo giá trị mặc định running
. Vì vậy, bạn có thể xác định tài sản animation-play-state
sau (http://jsfiddle.net/fRzwS/373/):
#tech {
-webkit-animation: moveSlideshow 10s linear infinite;
-webkit-animation-play-state:paused;
}
Hoặc bạn chỉ có thể sử dụng (http://jsfiddle.net/fRzwS/374/):
-webkit-animation: moveSlideshow 10s linear infinite paused;
Dưới đây là một ví dụ khác mà hoạt động trên cả Chrome và Firefox: http://jsfiddle.net/MaY5A/694/
đẹp bản demo btw. +1 Đây là một addon Mozilla;) http://jsfiddle.net/fRzwS/113/ –
cảm ơn, không thể tin rằng tôi đã bỏ lỡ nó, roXon bạn cần tiền tố -moz cho firefox – Neo
Tôi biết rằng ... Chỉ cần thay đổi nó trong bản trình diễn. (chỉnh sửa bình luận ở trên) –