代码示例:(标识:jsck_style_animationfillmode)
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
background: red;
position: relative;
animation: mymove 2s 2;
}
@keyframes mymove {
from {left: 0px;}
to {left: 200px;}
}
</style>
</head>
<body>
<h1>HTML Style 对象</h1>
<h2>animationFillMode 属性</h2>
<p>点击“试一试”按钮,让 DIV 元素保持上一个关键帧设置的样式:{left:200px;},当动画结束时。</p>
<button onclick="myFunction()">试一试</button>
<script>
function myFunction() {
document.getElementById("myDIV").style.animationFillMode = "forwards";
}
</script>
<div id="myDIV"></div>
</body>
</html>