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



我有一个文本幻灯片动画,但我正在使用,但文本没有在小屏幕上堆叠。 相反,它会在屏幕上运行。 我想在大屏幕和超大屏幕上将两个句子放在同一行上,并将其堆叠在较小的屏幕上。 到目前为止,无论大小如何,我都将其堆叠起来,在中以上看起来不错,但是文本在小屏幕上会从屏幕上流出。 关于我应该做什么的任何提示?

截图: 全屏幕 小屏幕

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>

在稍微摆弄了一下之后,我认为你不能通过正确定义你的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 */
}

尝试添加以下内容:

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

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

最新更新