I am trying to make a container that has children Horizontally and moves from left to right
Each of those children , when it reach the end of the container => goes to the start of the container
let’s imagine that it contain 4 children:
0% : ..1 | 2 | 3 | 4..
25% : ..4 | 1 | 2 | 3..
50% : ..3 | 4 | 1 | 2..
75% : ..2 | 3 | 4 | 1..
100% : ..1 | 2 | 3 | 4..
not like the carousel, but like the ring rolling (smooth )
for infinite time
Below
.container {
height: 200px;
width: 800px;
border: 1px solid #333;
overflow: hidden;
margin: 25px auto;
}
.box {
background: orange;
height: 180px;
margin: 10px;
animation-name: move;
animation-duration: 10s;
animation-iteration-count: infinite;
animation-direction: right;
animation-timing-function: linear;
display: flex;
}
.card {
background: #fff;
height: 150px;
min-width: 100px;
margin: 15px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.box:hover {
animation-play-state: paused;
}
@keyframes move {
0% {
margin-left: 000px;
}
25% {
margin-left: 100px;
}
50% {
margin-left: 200px;
}
75% {
margin-left: 300px;
}
100% {
margin-left: 400px;
}
}
<div class="container">
<div class="box">
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
</div>
</div>
is the code I have tried:
may use JavaScript.
2
Answers
here is the soulutiion I get from varpex :
it works good and beautifully.
Check this and let me know if this works 🙂