怎么让css动画一个执行完成之后再执行另外一个动画?
2017-07-17
展开全部
可以直接用css3写,或者用js定时器控制,看你具体要实现什么动画。
追问
就是我刚进网页有个缓慢的加载动效,然后在进入网页有另外一个动效,
2017-07-17
展开全部
<html>
<head>
<style>
@keyframes longer {
from {width: 100px;}
to {width: 200px;}
}
@-moz-keyframes longer {
from {width: 100px;}
to {width: 200px;}
}
@-webkit-keyframes longer {
from {width: 100px;}
to {width: 200px;}
}
@-o-keyframes longer {
from {width: 100px;}
to {width: 200px;}
}
#animator {
width: 100px;
height: 100px;
background: red;
}
.animation {
animation: longer 0.5s;
-moz-animation: longer 0.5s;
-webkit-animation: longer 0.5s;
-o-animation: longer 0.5s;
}
</style>
</head>
<body>
<div id="animator" class="animation"></div>
<亏型script>
var animator = document.getElementById('animator');
animator.addEventListener('消薯animationend', endHandler);
function endHandler() {
animator.removeEventListener('animationend', endHandler);
animator.className = '';
setTimeout(function () {
animator.className = 'animation';
}, 0);
}
<销桥猜/script>
</body>
</html>
<head>
<style>
@keyframes longer {
from {width: 100px;}
to {width: 200px;}
}
@-moz-keyframes longer {
from {width: 100px;}
to {width: 200px;}
}
@-webkit-keyframes longer {
from {width: 100px;}
to {width: 200px;}
}
@-o-keyframes longer {
from {width: 100px;}
to {width: 200px;}
}
#animator {
width: 100px;
height: 100px;
background: red;
}
.animation {
animation: longer 0.5s;
-moz-animation: longer 0.5s;
-webkit-animation: longer 0.5s;
-o-animation: longer 0.5s;
}
</style>
</head>
<body>
<div id="animator" class="animation"></div>
<亏型script>
var animator = document.getElementById('animator');
animator.addEventListener('消薯animationend', endHandler);
function endHandler() {
animator.removeEventListener('animationend', endHandler);
animator.className = '';
setTimeout(function () {
animator.className = 'animation';
}, 0);
}
<销桥猜/script>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询