【问题标题】:combine css animation with transform将 css 动画与变换相结合
【发布时间】:2017-10-21 22:54:13
【问题描述】:

是否可以将 css 转换与一些动画相结合?

我有这个 tarnsform

transform: translate(-10%, 0px); left: 0px;

它可以很好地为滑块向左、向右滚动设置动画

但我想在 不透明度 0 到 1

中添加一些 动画淡入淡出

【问题讨论】:

  • 我将尝试设置一个小的 codepen 示例,我尝试的是:在动态 translate() 上淡入幻灯片。

标签: css css-transitions css-animations css-transforms


【解决方案1】:

如果我理解正确,您希望将翻译和不透明度都包含在动画中,请使用:

div {
  width: 100px;
  height: 100px;
  background: red;
  animation-name: fromleft;
  animation-delay: 0s;
  animation-duration: 0.8s;
  animation-fill-mode: backwards;
  animation-timing-function: ease-out;
}

@keyframes fromleft {
  0% {
    transform: translateX(-100px);
    opacity: 0;
  }
  100% {
    transform: translateX(0px);
    opacity: 1;
  }
}
<div>

</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-24
    • 2014-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-28
    • 2014-09-14
    • 2021-03-23
    相关资源
    最近更新 更多