试图用文本制作divs以提高无限循环
我试图使divs向上移动无限循环,而我在关键框架设置中挣扎。
谁能帮我弄清楚我错了并纠正我的错误,我敢肯定这是如此简单,我只是没有注意到。
非常感谢。
#container {
color:#999;
text-transform: uppercase;
font-size:60px;
font-weight:bold;
padding-top:200px;
position:fixed;
width:100%;
bottom:45%;
display:block;
}
#flip {
height:100px;
overflow:hidden;
}
#flip > div > div {
color:#fff;
padding:10px 12px 10px 12px;
height:65px;
margin-bottom:45px;
display:inline-block;
}
#flip div:first-child {
animation: show 5s linear infinite;
}
#flip div div {
background:#42c58a;
}
#flip div:first-child div {
background:#4ec7f3;
}
#flip div:last-child div {
background:#DC143C;
}
@keyframes show {
0% {transform: translateY(0);}
50% {transform: translateY(50%);}
100% {transform: translateY(100%);}
}
<div id=container>
ENDLESS
<div id=flip>
<div><div>SMOOTHIES</div></div>
<div><div>MILKSHAKES</div></div>
<div><div>FRUIT SHAKES</div></div>
<div><div>COCTAILS</div></div>
<div><div>FRUIT SHAKES</div></div>
</div>
OPTIONS!
</div>
Im trying to make divs move up infinity loop, and i'm struggle with the keyframes settings.
Can anyone help me figure out where I'm wrong and correct my mistake, I'm sure it's something so simple I just did not notice it.
Thank you very much.
#container {
color:#999;
text-transform: uppercase;
font-size:60px;
font-weight:bold;
padding-top:200px;
position:fixed;
width:100%;
bottom:45%;
display:block;
}
#flip {
height:100px;
overflow:hidden;
}
#flip > div > div {
color:#fff;
padding:10px 12px 10px 12px;
height:65px;
margin-bottom:45px;
display:inline-block;
}
#flip div:first-child {
animation: show 5s linear infinite;
}
#flip div div {
background:#42c58a;
}
#flip div:first-child div {
background:#4ec7f3;
}
#flip div:last-child div {
background:#DC143C;
}
@keyframes show {
0% {transform: translateY(0);}
50% {transform: translateY(50%);}
100% {transform: translateY(100%);}
}
<div id=container>
ENDLESS
<div id=flip>
<div><div>SMOOTHIES</div></div>
<div><div>MILKSHAKES</div></div>
<div><div>FRUIT SHAKES</div></div>
<div><div>COCTAILS</div></div>
<div><div>FRUIT SHAKES</div></div>
</div>
OPTIONS!
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在为完整视图端口进行动画,
#flip
。取而代之的是,您可以将所有Divs包装在容器中,
#filp-container
,并为其进行动画。这是完整的编辑代码,对每个更改都有评论:
You're animating the full view port,
#flip
.Instead you can wrap all the divs in a container,
#filp-container
, and animate it.Here is the full edited code with a comment for each change: