如何进行 2 个链式变换,第一个有过渡,后面没有过渡?

How to make 2 chained transforms, the first with transition and the following with no transotions?

我需要添加 2 个链接变换,一个有动画,第二个没有动画。类似于:

transition: transform 500ms;
transform: translateX(100%);

然后,500 毫秒后:

transform: translateX(200%); // this time without any transition or, in other words, with transition time == 0ms.

因此对象将通过动画平移 X 轴上的第一个 100% 宽度,而不是在没有动画的情况下直接移动到 200%,只是简单的设置。

怎么办?

您可以使用如下动画:

.box {
  width: 100px;
  height: 100px;
  background: red;
  animation: change 1s forwards;
}

@keyframes change {
  50% {
    transform: translateX(100%);
  }
  50.1%, 100% { /*change right after 50%*/
    transform: translateX(200%);
  }
}
<div class="box"></div>

有了过渡你可以考虑2个div:

.container {
  display:inline-block;
  transition:0s 0.5s transform;
}

.box {
  width: 100px;
  height: 100px;
  background: red;
  transition:0.5s transform;
}

body:hover .container,
body:hover .box{
  transform: translateX(100%);
}
<div class="container">
<div class="box"></div>
</div>