
css3中可以使用animation-delay属性设置动画开始时间,使用animation-duration属性设置动画完成一个周期所花费时间。
css3设置动画开始时间示例:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:mymove 5s infinite;
animation-delay:2s;
/*Safari and Chrome*/
-webkit-animation:mymove 5s infinite;
-webkit-animation-delay:2s;
}
@keyframes mymove
{
from {left:0px;}
to {left:200px;}
}
@-webkit-keyframes mymove /*Safari and Chrome*/
{
from {left:0px;}
to {left:200px;}
}
</style>
</head>
<body>
<div></div>
</body>
</html>animation-delay 属性定义动画什么时候开始。
animation-delay 值单位可以是秒(s)或毫秒(ms)。
语法:
animation-delay: time;
time:可选。定义动画开始前等待的时间,以秒或毫秒计。默认值为0
css3设置动画开始时间示例:
<html><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:mymove infinite;
animation-duration:2s;
/* Safari and Chrome */
-webkit-animation:mymove infinite;
-webkit-animation-duration:2s;
}
@keyframes mymove
{
from {top:0px;}
to {top:200px;}
}
@-webkit-keyframes mymove /* Safari and Chrome */
{
from {top:0px;}
to {top:200px;}
}
</style>
</head>
<body>
<p><strong>注意:</strong> animation-duration属性不兼容 Internet Explorer 9 以及更早版本的浏览器.</p>
<div></div>
<p><b>注意:</b> 要指定动画属性。否则时间若是0,动画不会进行。</p>
</body>
</html>animation-duration属性定义动画完成一个周期需要多少秒或毫秒。
语法:
animation-duration: time;
time:指定动画播放完成花费的时间。默认值为 0,意味着没有动画效果。
推荐:css3手册
以上就是css3怎么设置动画时间?的详细内容,更多请关注易知道|edz.cc其它相关文章!














