EDIT
As the author changed the definition of what he really needed I did this other example trying to simulate the looping
of slider. But for that I needed to "clone" the last items of the content in hand. The idea here is that when the animation does the loop
the content of the end is equal to the beginning, so the user does not notice the loop
See how it looked in the example.
.container {
width: 200px;
height: 220px;
background-color: #ddd;
display: flex;
flex-wrap: wrap;
position: relative;
border: 1px solid;
overflow: hidden;
}
.slider {
background-color: #ddd;
display: flex;
flex-wrap: wrap;
animation: anima 4s infinite linear;
position: relative;
}
.logo {
margin: 10px;
width: 80px;
height: 80px;
background-color: #333;
}
@keyframes anima {
10% {
transform: translateY(0);
}
100% {
/* 180px e a altura do container descontando as margens pode ser que vc tenha que ajustar esse tamanho dependo da altura do seu container */
transform: translateY(calc(-100% + -180px));
}
}
<div class="container">
<div class="slider">
<div class="logo">
<img src="https://unsplash.it/81/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<!-- clones para fazer o looping -->
<div class="logo">
<img src="https://unsplash.it/81/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
</div>
</div>
Same option as the site that the questioner had previously requested
Follows a template made only with CSS. The idea here is that I one .container
that inside him has another container called .slider
, this in turn has inside it all logos. Now just you do the .slider
move up 100% of the height itself, for this I used transform:translateY(calc(-100% + a altura do .container))
thus the .slider
goes all the way up, but doesn’t leave . container empty...
Applied logic:
To better understand see the code:
(I left some comments on CSS, read!)
OBS: The only caveat is that the more items you have inside the slider, the faster it will pass. I explain: If the Slide is 100px high and has 10s to travel its own height it displaces 10px per Second. Now if he is 200px high in 10s he will now shift 20px per second, soon he will pass the animation faster. To fix this you just need to increase the animation time from 10s to 20s :D
.container {
width: 200px;
height: 220px;
background-color: #ddd;
display: flex;
flex-wrap: wrap;
position: relative;
border: 1px solid;
overflow: hidden;
}
.slider {
position: absolute;
display: flex;
flex-wrap: wrap;
transform: translateY(0);
animation: anima 6s infinite alternate linear;
}
.logo {
margin: 10px;
width: 80px;
height: 80px;
}
@keyframes anima {
10% {
transform: translateY(0);
}
20% {
/* aqui eu repito a propriedade para deixar o slide para um tempo antes de rodar */
transform: translateY(0);
}
90% {
/* aqui o slide sobe 100% da própria altura, menos a altura do container */
transform: translateY(calc(-100% + 220px));
}
100% {
transform: translateY(calc(-100% + 220px));
}
}
<div class="container">
<div class="slider">
<div class="logo">
<img src="https://unsplash.it/80/81" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/81/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/81/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/81" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/81/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/80" alt="">
</div>
<div class="logo">
<img src="https://unsplash.it/80/81" alt="">
</div>
</div>
</div>
Dude, do you talk about the banner with the testimonials or the banner that has the logos? If it’s the logo banner and you get something very close with just CSS and a few lines of code! You don’t even need JS or jQuery... If you’re interested I can make an example
– hugocsl
@hugocsl Yes, those who have the logos. If you can send the example
– user128653