[英]CSS3 image marquee using animation isn't working well with more than one image
I have this HTML: 我有这个HTML:
<div id="images_container" style="z-index: 900;">
<div id="images">
<img src="images/cust.png">
<img src="images/cust.png">
<img src="images/cust.png">
</div>
</div>
I want to make the images move from the right of the screen to the left using the animation CSS3. 我想使用动画CSS3使图像从屏幕的右侧移动到左侧。 I got it working: 我得到它的工作:
scrolls the first image. 滚动第一张图像。
starts showing the second image (by the way, the image is the same image 3 times). 开始显示第二张图像(顺便说一句,该图像是同一图像的3倍)。
the first image almost finishes scrolling. 第一张图像几乎完成滚动。
the whole div sort of "jumps" and loads the first image from the beginning. 整个div会“跳转”并从头开始加载第一张图片。
It doesn't look aesthetic at all. 它看起来根本不美观。
This is the CSS I have so far: 这是我到目前为止拥有的CSS:
@-webkit-keyframes ticker {
0% {margin-left: 0;}
100% {margin-left: -1956px;}
}
@-moz-keyframes ticker {
0% {margin-left: 0;}
100% {margin-left: -1956px;}
}
@-ms-keyframes ticker {
0% {margin-left: 0;}
100% {margin-left: -1956px;}
}
@keyframes ticker {
0% {margin-left: 0;}
100% {margin-left: -1956px;}
}
#first #images_container {
position: absolute;
height: 60px;
width: 100%;
overflow: hidden;
margin: -67px auto 0;
z-index: 900;
}
#first #images {
-webkit-animation: ticker 45s linear infinite;
-moz-animation: ticker 45s linear infinite;
-ms-animation: ticker 45s linear infinite;
animation: ticker 45s linear infinite;
width: 10000px;
}
More relevant info about the images: they are 3294px width each. 有关图像的更多相关信息:它们的宽度均为3294px。
Update: 更新:
When I change this: 当我更改此:
@-webkit-keyframes ticker {
0% {margin-left: 0;}
100% {margin-left: -1956px;}
}
to this: 对此:
@-webkit-keyframes ticker {
0% {margin-left: 0;}
100% {margin-left: -10000;}
}
All the images run well, but the speed of the marquee increases. 所有图像运行良好,但选取框的速度增加。
Any solution for that? 有什么解决办法吗?
Update Final Answer: 更新最终答案:
I changed the seconds from 45 to 160: 我将秒数从45更改为160:
#first #images {
-webkit-animation: ticker 160s linear infinite;
-moz-animation: ticker 160s linear infinite;
-ms-animation: ticker 160s linear infinite;
animation: ticker 160s linear infinite;
width: 10000px;
}
Solved my problem :) 解决了我的问题:)
Because the width of the images is high, I gave it a big numger for the 'margin-left' on the keyframes. 由于图像的宽度很高,因此我为关键帧的“ margin-left”(左边缘)设置了较大的编号。
@-webkit-keyframes ticker {
0% {margin-left: 0;}
100% {margin-left: -10000px;}
}
@-moz-keyframes ticker {
0% {margin-left: 0;}
100% {margin-left: -10000px;}
}
@-ms-keyframes ticker {
0% {margin-left: 0;}
100% {margin-left: -10000px;}
}
@keyframes ticker {
0% {margin-left: 0;}
100% {margin-left: -10000px;}
}
Because the image is really long, 45s wont be slow enough (for me), so I gave it a high number. 因为图像真的很长,所以45s不会足够慢(对我来说),所以我给它一个很大的数字。 like 160s. 像160年代
#first #images {
-webkit-animation: ticker 160s linear infinite;
-moz-animation: ticker 160s linear infinite;
-ms-animation: ticker 160s linear infinite;
animation: ticker 160s linear infinite;
width: 10000px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.