【问题标题】:Keyframe text translate and rotate not working [duplicate]关键帧文本翻译和旋转不起作用[重复]
【发布时间】:2020-04-08 10:43:53
【问题描述】:

我喜欢翻译并将h1 元素旋转到它的位置。但是翻译不起作用,并且在旋转文本时会离开它的位置并返回,但我希望它一直在它的位置。

代码:

.article1 h1{
    font-size: 50px;
    font-weight: 600;
    margin-top: 130px;
    margin-bottom: 12px; 
    animation: tilt 2s ease 3;
} 
@keyframes tilt{
  0% {
    transform: translateY(200px);
    transform: rotateY(0deg);
    opacity: 0.2;
  }
  100% {
    transform: translateY(0px);
    transform: rotateY(360deg);
    opacity: 1;
  }
}

我需要 h1 从 200px 顶部到达它的位置,并在下降时进行 360 度 Y 旋转,这可能吗?

【问题讨论】:

  • 可以分享你的html代码吗?
  • <article class="article1"> <h1>What we do.</h1> <h3>We provide Top-Quality Plants you choose right to your doorstep</h3> <button class="button">Explore</button> </article>
  • 你可以做嵌套的 div 并在每个上放一个动画。

标签: css css-animations css-transitions


【解决方案1】:

您的rotateY 转换正在覆盖您的translateY 转换,您需要在一个转换行中同时包含rotateY 和translateY

试试这个:

@keyframes tilt{
  0% {
    transform: translateY(200px) rotateY(0deg);
    opacity: 0.2;
  }
  100% {
    transform: translateY(0px) rotateY(360deg);
    opacity: 1;
  }
}

【讨论】:

  • 谢谢,它们现在都可以工作了,但是当元素旋转时它仍然向右移动并返回左,有什么办法让它在一个地方旋转吗?
  • 我不确定我是否明白你在问什么。你的 CSS 说动画发生了 3 次,也许 animation: tilt 2s ease 1; 会修复它?
猜你喜欢
  • 2012-01-11
  • 2016-07-27
  • 2016-10-08
  • 1970-01-01
  • 1970-01-01
  • 2015-08-26
  • 2021-05-31
  • 2019-03-02
  • 1970-01-01
相关资源
最近更新 更多