I have posted before about CSS Keyframe animation and tried a different way of using delays.
I had css continous slider of 5 divs which worked fine. However I needed to remove two of the divs so there is only three.
.wrapper{
position: relative;
height: 330px;
display: grid;
overflow: hidden;
width:600px;
background:#f1f1f1;
}
.slide {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
animation: slider 9s cubic-bezier(0.5, 1, 0.5, 1) infinite;
color:#fff;
font-size:30px;
text-align:center;
padding-top:25%;
}
.slide:first-of-type {
animation-delay: -9s;
background:red;
}
.slide:nth-of-type(2) {
animation-delay: -6s;
background:blue;
}
.slide:last-of-type {
animation-delay: -3s;
background:black;
}
@keyframes slider {
0% {
transform: translateX(0);
opacity: 1;
}
16% {
transform: translateX(0);
opacity: 1;
}
20% {
transform: translateX(100%);
opacity: 1;
}
75% {
transform: translateX(100%);
opacity: 0;
}
76% {
transform: translateX(-100%);
opacity: 0;
}
96% {
transform: translateX(-100%);
opacity: 1;
}
}
<div class="wrapper">
<div class="slide">
1
</div>
<div class="slide">
2
</div>
<div class="slide">
3
</div>
</div>
So I have tried changing the animation to 9s, 3 seconds per div. I have changed the delay on the divs to -9s, -6s, -3s respectively but I have a pause in between each div sliding in.
I have tried to alter the percentages which is where I believe I am going wrong.
I am wondering if anyone can give me some help on the percentages I need to change or if there is a formula to use so I can switch up the amount of divs in the future if need be?