Create an infinite scrolling animation with CSS ๐ฅ
Avneesh Agarwal
1 min read
You might have seen an infinite autoscrolling animation on a website with some logos. This scrolling animation looks really good. So let's see how we can do that
Creating a container with 6 divs inside it
<div class="container">
<div class="pink"></div>
<div class="blue"></div>
<div class="yellow"></div>
<div class="orange"></div>
<div class="purple"></div>
<div class="aqua"></div>
</div>
Adding simple styles to the container and giving the divs a width, height, and different colors. You can also have images here.
.container {
overflow: hidden;
display: flex;
height: 500px;
width: 1500px;
margin: 0 auto;
}
.container div {
height: 400px;
min-width: 300px;
margin-left: 100px;
}
.pink {
background-color: pink;
}
.blue {
background-color: blue;
}
.yellow {
background-color: yellow;
}
.orange {
background-color: orange;
}
.purple {
background-color: purple;
}
.aqua {
background-color: aqua;
}
Adding a keyframe -
@keyframes slide {
0% {
transform: translate3d(0, 0, 0);
}
100% {
transform: translate3d(-1500px, 0, 0); /* The image width */
}
}
Using the keyframe animation in the container
.container div {
height: 400px;
min-width: 300px;
margin-left: 100px;
animation: slide 15s linear infinite;
}
Ta-da it was as simple as this to get it working!
Hope you liked this mini-tutorial, I will meet you in the next one โ๐ป
Useful links-
120
Subscribe to my newsletter
Read articles from Avneesh Agarwal directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Avneesh Agarwal
Avneesh Agarwal
16 yo full stack web3 developer building cool shit and teaching others