gpt4 book ai didi

javascript - 如何让关键帧动画停止在最后一个动画上

转载 作者:行者123 更新时间:2023-11-28 04:07:20 25 4
gpt4 key购买 nike

我希望在我的 100% 关键帧上停止我的动画。

在这里,jQuery 显示在底部。我想完全弄清楚的是如何为这些框设置动画,这样如果您单击顶部的任何一个,它就会移动到底部,然后底部的移动到顶部。有什么想法吗?

<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
@keyframes active {
0% {
transform: translateX(0px);
}
33% {
transform: translateX(105px);
}
66% {
transform: rotateY(180deg) translateY(210px);
}
100% {
transform: rotateY(0deg) translateY(210px);
}
}
.all-wrap {border: 1px solid black;
}
.container {width:100px;height:100px;background-color:red;
perspective:400px;perspective-origin:50% 100px;
margin-right:auto;
display: block;
border: 2px solid purple;
animation-fill-mode: forwards;
background-repeat: no-repeat;
}
.containerActive {
animation: active 3s ease-in-out;
animation-fill-mode: forwards;
animation-iteration-count: 1;
transform-style: preserve-3d;
animation-direction: normal;
}
</style>
</head>
<body>
<div class="all-wrap">
<div class="container">
</div>
<div class="container">
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="/js/rotate.js"></script>
</body>
</html>

/* Here is the jQuery: */

$('[class*="container"]').on('click', function(){
$(this).toggleClass('containerActive');
});

最佳答案

应使用以下代码实现在 100% 关键帧上停止:

animation-fill-mode: forwards;

此问题之前已在此处解决: Stopping a CSS3 Animation on last frame

关于javascript - 如何让关键帧动画停止在最后一个动画上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42893772/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com