Create an infinite scrolling animation with CSS ?

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 c…


This content originally appeared on DEV Community and was authored by Avneesh Agarwal

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

Let's do it

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!

https://www.loom.com/share/a2339e51fcf942a99de46264190e3c94

Hope you liked this mini-tutorial, I will meet you in the next one ✌?

Useful links-

Code

Social links


This content originally appeared on DEV Community and was authored by Avneesh Agarwal


Print Share Comment Cite Upload Translate Updates
APA

Avneesh Agarwal | Sciencx (2021-08-22T07:12:35+00:00) Create an infinite scrolling animation with CSS ?. Retrieved from https://www.scien.cx/2021/08/22/create-an-infinite-scrolling-animation-with-css-%f0%9f%92%a5/

MLA
" » Create an infinite scrolling animation with CSS ?." Avneesh Agarwal | Sciencx - Sunday August 22, 2021, https://www.scien.cx/2021/08/22/create-an-infinite-scrolling-animation-with-css-%f0%9f%92%a5/
HARVARD
Avneesh Agarwal | Sciencx Sunday August 22, 2021 » Create an infinite scrolling animation with CSS ?., viewed ,<https://www.scien.cx/2021/08/22/create-an-infinite-scrolling-animation-with-css-%f0%9f%92%a5/>
VANCOUVER
Avneesh Agarwal | Sciencx - » Create an infinite scrolling animation with CSS ?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/08/22/create-an-infinite-scrolling-animation-with-css-%f0%9f%92%a5/
CHICAGO
" » Create an infinite scrolling animation with CSS ?." Avneesh Agarwal | Sciencx - Accessed . https://www.scien.cx/2021/08/22/create-an-infinite-scrolling-animation-with-css-%f0%9f%92%a5/
IEEE
" » Create an infinite scrolling animation with CSS ?." Avneesh Agarwal | Sciencx [Online]. Available: https://www.scien.cx/2021/08/22/create-an-infinite-scrolling-animation-with-css-%f0%9f%92%a5/. [Accessed: ]
rf:citation
» Create an infinite scrolling animation with CSS ? | Avneesh Agarwal | Sciencx | https://www.scien.cx/2021/08/22/create-an-infinite-scrolling-animation-with-css-%f0%9f%92%a5/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.