html - 如何停止我的动画

标签 html css

我希望 block 从一个点移动到另一个点。 在 fiddle 中,您可以看到动画结束后, block 返回到其第一个位置。

如何防止这种情况发生?

http://jsfiddle.net/2nT2S/

CSS

div
{
width:100px;
height:100px;
background:black;
position:relative;
animation:myfirst 2s;
-webkit-animation:myfirst 2s; /* Safari and Chrome */
}

@keyframes myfirst
{
from { left:0px; top:0px; }
to { left:0px; top:200px; }
}

@-webkit-keyframes myfirst /* Safari and Chrome */
{
from { left:0px; top:0px; }
to { left:0px; top:200px; }
}    
</style>

最佳答案

只需添加转发 animation-fill-mode到动画:

animation:myfirst 2s forwards;
-webkit-animation:myfirst 2s forwards; /* Safari and Chrome */

jsfiddle

关于html - 如何停止我的动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20747526/

相关文章:

html - 如果它们是禁用祖先的一部分,我如何突出显示无效输入?

Java CSS Sprite 库

javascript - 将 child 链接到在 Chrome 中工作但在 Internet Explorer 中不工作的按钮

css - 替代 CSS 定位(静态、相对、绝对、固定)?

html - 将大参数传递给 iframe

javascript - 如何从 JavaScript 文件中检查正在使用哪个 HTML?

html - child 如何仅使用 CSS 访问其 parent 的属性(property)?是否可以?

javascript - 使用嵌套的 ngFor 遍历两个单独的数组

css - 防止 ionic 中的第一个输入焦点

html - 调整大小的简单布局问题