<html>
<head>
<style>
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:mymove 5s infinite;
animation-delay:10s;
/*Safari、Chrome 和 Opera*/
-webkit-animation:mymove 5s infinite;
-webkit-animation-delay:10s;
}
@keyframes mymove
{
from {left:0px;}
to {left:200px;}
}
/*Safari、Chrome 和 Opera*/
@-webkit-keyframes mymove
{
from {left:0px;}
to {left:200px;}
}
</style>
</head>
<body>
<p>动画将在页面完成加载后 10 秒开始。</p>
<p>点击“尝试一下”按钮把动画的延迟减少到三秒。</p>
<button onclick="myFunction()">尝试一下</button>
<script>
function myFunction()
{
document.getElementById("myDIV").style.animationDelay = "3s";
// 针对 Chrome、Safari 和 Opera 的代码
document.getElementById("myDIV").style.WebkitAnimationDelay = "3s";
}
</script>
<p>请注意,延迟是从页面完成加载后开始计算,而不是从您点击按钮开始计算。</p>
<p><strong>注意:</strong>只有 Firefox 支持 animationDelay 属性。</p>
<div id="myDIV"></div>
</body>
</html>