html - 元素具有 css 样式和转换 : translate animation

标签 html css

<分区>


关闭 5 年前

如果我将动画应用于具有 css 样式的元素,并进行转换:翻译 例如

transform: translateY(100px);

在动画结束时,元素跳转到所需位置。如何避免这种跳跃并使动画流畅地到达所需位置?

http://jsfiddle.net/alexchetv/bc49LnLt/

最佳答案

只需删除最后一个关键帧:

to {
  transform: none;
}

div {
    width:20px;
    height:20px;
    background-color:#f00;
    animation:bounceInDown 1s;
    transform: translateY(100px);
}

@keyframes bounceInDown {
  from, 60%, 75%, 90% {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
  }

  0% {
    opacity: 0;
    transform: translate3d(0, -3000px, 0);
  }

  60% {
    opacity: 1;
    transform: translate3d(0, 25px, 0);
  }

  75% {
    transform: translate3d(0, -10px, 0);
  }

  90% {
    transform: translate3d(0, 5px, 0);
  }
}
<div></div>

关于html - 元素具有 css 样式和转换 : translate animation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49668628/

上一篇:html - 在 HTML 表格中使用 CSS 交叉

下一篇:css - 定位最后一个活跃的 li

相关文章:

jquery - 在 jQuery 中结合 .text() 和 .css() 方法

javascript - 使用 jQuery 将数组中的图像和文本转换为 Div?

javascript - 用 onClick 事件模拟按键

javascript - 晚餐成本计算器无法将字符串转换为整数

html - 边框底部样式。使边框底部与导航栏菜单宽度相同

css - 风格层叠怪异

javascript - 我可以在 Android 上的 Chrome 上获取绝对设备方向吗?

javascript - jQuery 解析 xml 并按特定属性分组

html - 为什么要在 HTML 中使用容器 div?

javascript - Angular 2 将输入绑定(bind)到函数调用