我有一个正在使用的文本幻灯片动画,但是文本不会在小屏幕上堆积。相反,它从屏幕上运行。我想在大屏幕和超大屏幕上将两个句子放在同一行上,并将其堆叠在较小的屏幕上。到目前为止,无论大小如何,我都可以将其堆叠起来,在中等或以上的尺寸上看起来都不错,但是在小屏幕上,文本不在屏幕上显示。关于我应该做什么的任何提示?
屏幕截图: 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>
答案 0 :(得分:0)
尝试添加此内容:
@media screen and (min-width: 480px) {
html {
font-size: 75%;
}
}
该字体现在应该在较小的屏幕上看起来不错。您可以将min-width
和自适应font-size
的值更改为您认为最合适的值。
答案 1 :(得分:0)
稍微摆弄一下之后,我认为仅仅定义正确的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 */
}