代码示例:(标识:css_animation-delay)
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf8" />
<script type="text/javascript">
<!--
function test_demo_val(strValue)
{
var strId="MyDIV"
document.getElementById(strId).style.animationDelay=strValue;
document.getElementById(strId).style.WebkitAnimationDelay=strValue;
document.getElementById(strId).style.MozAnimationDelay=strValue;
document.getElementById("CodeValue").innerHTML=strValue;
}
function tiy_onload()
{
var PreVal=""
PreVal=document.getElementById("PreSelectedValue").value
if (PreVal!="")
{
test_demo_val(PreVal)
var x=document.getElementsByTagName("input")
var l=x.length
for (i=0;i<l;i++)
{
if (x[i].value==PreVal)
{
x[i].checked=true
}
}
}
}
function test_demo(obj)
{
test_demo_val(obj.value)
}
//-->
</script>
<style>
div#MyDIV
{
width:100px;
height:100px;
background:red;
position:relative;
animation:mymove 5s 1;
-webkit-animation:mymove 5s 1;
}
@keyframes mymove
{
from {left:0px;}
to {left:330px;}
}
@-webkit-keyframes mymove /* Safari and Chrome */
{
from {left:0px;}
to {left:330px;}
}
div#MyDIV
{
animation-delay:1s;
-webkit-animation-delay:1s;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="SelArea">
<h2>CSS 属性:</h2>
<h3>animation-delay:</h3>
<form action="javascript:return false;">
<ul>
<input type="hidden" id="PreSelectedValue" value="" />
<li><input autocomplete="off" type="radio" name="rpos" onClick="test_demo(this)" id="value_1" value="1s" checked="checked" />1s</li>
<li><input autocomplete="off" type="radio" name="rpos" onClick="test_demo(this)" id="value_2" value="2s" />2s</li>
<li><input autocomplete="off" type="radio" name="rpos" onClick="test_demo(this)" id="value_3" value="5s" />5s</li>
<li><input autocomplete="off" type="radio" name="rpos" onClick="test_demo(this)" id="value_4" value="-2s" />-2s</li>
</ul>
</form>
</div>
<div id="result">
<h2>结果:</h2>
<div id="DemoArea">
<div id="MyDIV"></div>
</div>
<h2>CSS 代码:</h2>
<pre id="CodeArea">
div#MyDIV
{
animation-delay:<span id="CodeValue">1s</span>;
}
</pre>
</div>
</div>
</body>
<script type="text/javascript">tiy_onload()</script>
</html>