我寫了一個css3動畫,它只執行一次。動畫效果很好,但動畫完成後會重置。我怎樣才能避免這一點,我想保持結果而不是重置它。如何在完成後防止css3動畫重置?
$(function() {
$("#fdiv").delay(1000).addClass("go");
});
#fdiv {
width: 10px;
height: 10px;
position: absolute;
margin-left: -5px;
margin-top: -5px;
left: 50%;
top: 50%;
background-color: red;
}
.go {
-webkit-animation: spinAndZoom 1s 1;
}
@-webkit-keyframes spinAndZoom {
0% {
width: 10px;
height: 10px;
margin-left: -5px;
margin-top: -5px;
-webkit-transform: rotateZ(0deg);
}
100% {
width: 400px;
height: 400px;
margin-left: -200px;
margin-top: -200px;
-webkit-transform: rotateZ(360deg);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="fdiv"></div>
這裏是demo。
未來的人請不要在這些答案中使用任何供應商前綴。如果您的目標瀏覽器仍然需要這些,然後使用自動工具來放置這些,如[Autoprefixer](https://github.com/postcss/autoprefixer)。 –