关于如何使此文本 CSS 动画在小屏幕上响应有任何想法吗?

Any idea on how to make this text CSS animation responsive on small screens?

我有一个正在使用的文本滑入动画,但文本不会在小屏幕上堆叠。相反,它跑出了屏幕。我想在大屏幕和超大屏幕上将两个句子放在同一行,并在较小的屏幕上堆叠。到目前为止,无论尺寸如何,我都将它堆叠起来,在中等和更高的屏幕上看起来不错,但文本在小屏幕上会跑出屏幕。关于我应该做什么的任何提示?

截图: Full screen Small screen

body {
  text-align: center;
  background: linear-gradient(141deg, #ccc 25%, #eee 40%, #ddd 55%);
  color: #555;
  font-weight: 300;
  font-size: 32px;
  padding-top: 40vh;
  height: 100vh;
  overflow: visible;
  -webkit-backface-visibility: hidden;
  -webkit-perspective: 1000;
  -webkit-transform: translate3d(0, 0, 0);
}

.intro {
  display: inline-block;
  overflow: hidden;
  white-space: normal;
}

.intro:first-of-type {
  animation: showup 7s infinite;
}

.intro~.intro {
  width: 0px;
  animation: reveal 7s infinite;
  white-space: normal;
}

.intro~.intro span {
  margin-left: -355px;
  animation: slidein 7s infinite;
  white-space: normal;
}

@keyframes showup {
  0% {
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes slidein {
  0% {
    margin-left: -800px;
  }
  20% {
    margin-left: -800px;
  }
  35% {
    margin-left: 0px;
  }
  100% {
    margin-left: 0px;
  }
}

@keyframes reveal {
  0% {
    opacity: 0;
    width: 0px;
  }
  20% {
    opacity: 1;
    width: 0px;
  }
  30% {
    width: 650px;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    width: 650px;
  }
}

p {
  font-size: 12px;
  color: #999;
}
<div class="container-fluid">
  <div class="intro">Hello.</div>
  <div class="intro col-xs-12">
    <span>My name is Nate and I need this responsive</span>
  </div>
</div>

尝试添加这个:

@media screen and (min-width: 480px) {
      html {
      font-size: 75%;
      }
    }

该字体现在在较小的屏幕上应该看起来不错。您可以将 min-width 和响应式 font-size 值更改为您认为最有效的值。

稍微摆弄一下后,我认为您无法通过恰到好处地定义CSS 动画来获得您想要的效果。最好的办法是为不同的屏幕宽度设置不同的行为,使用 @media 规则:

@media screen and (max-width: 649px) {
    /* Rules for small screens */
}
@media screen and (min-width: 650px) and (max-width: 999px) {
    /* Rules for medium screens */
}
@media screen and (min-width: 1000px) {
    /* Rules for large screens */
}