I'm currently working on creating a custom CSS ticker by referencing various examples online. I've managed to develop something that functions well, but it seems to only cycle through the initial 4 list items. Once it reaches the 4th item, it loops back to the beginning.
I'm struggling to identify what causes this looping behavior and how I can display the 5th item. My goal is to have the ability to scroll through a list that could potentially contain hundreds of items.
Snippet....
@keyframes ticker {
0% {margin-top: 0}
25% {margin-top: -30px}
50% {margin-top: -60px}
75% {margin-top: -90px}
100% {margin-top: 0}
}
.news {
box-shadow: inset 0 -15px 30px rgba(0,0,0,0.4), 0 5px 10px rgba(0,0,0,0.5);
width: 300px;
height: 30px;
margin: 20px auto;
overflow: hidden;
border-radius: 4px;
padding: 3px;
-webkit-user-select: none
}
.news span {
float: left;
color: #fff;
padding: 6px;
position: relative;
top: 1%;
border-radius: 4px;
box-shadow: inset 0 -15px 30px rgba(0,0,0,0.4);
font: 16px 'Source Sans Pro', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-webkit-user-select: none;
cursor: pointer
}
.news ul {
float: left;
padding-left: 20px;
animation: ticker 10s cubic-bezier(1, 0, .5, 0) infinite;
-webkit-user-select: none
}
.news ul li {line-height: 30px; list-style: none }
.news ul li a {
color: #fff;
text-decoration: none;
font: 14px Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-webkit-user-select: none
}
.news ul:hover { animation-play-state: paused }
.news span:hover+ul { animation-play-state: paused }
/* OTHER COLORS */
.red { background: #d23435 }
.red span { background: #c22b2c }
<div class="news red">
<span>Latest News</span>
<ul>
<li><a href="#">Text 1 - Short Description</li>
<li><a href="#">Text 2 - Short Description</a></li>
<li><a href="#">Text 3 - Short Description</a></li>
<li><a href="#">Text 4 - Short Description</a></li>
<li><a href="#">Text 5 - Short Description</a></li>
</ul>
</div>