Home > Software engineering >  Logo Carousel Not in a ring like loop
Logo Carousel Not in a ring like loop

Time:09-30

I have the following code for Client Logo Slider modified from a YouTube tutorial. While the animation is infinite, it first runs an instance of logos and then stops, and starts from the beginning. The intended result was a continuous flow of logos without a break. I am not sure where it is going wrong.

.slider-area h2 {
  text-align: center;
  font-size: 60px;
  font-weight: 500;
  letter-spacing: 2px;
  margin: 100px 0 30px 0;
  color: rgb(0, 0, 0);
}

.wrapper {
  width: 800px;
  margin: 0 auto;
  display: flex;
  overflow: hidden;
}

.item {
  animation: animate 10s linear infinite;
  padding: 20px;
}

@keyframes animate {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-800px, 0, 0);
  }
}

@media (max-width:767px) {}
<div >
  <h2>My Tools</h2>
  <div >
    <div ><img alt="" src="https://i.stack.imgur.com/EKRTj.jpg"></div>
    <div ><img alt="" src="https://i.stack.imgur.com/EKRTj.jpg"></div>
    <div ><img alt="" src="https://i.stack.imgur.com/EKRTj.jpg"></div>
    <div ><img alt="" src="https://i.stack.imgur.com/EKRTj.jpg"></div>
    <div ><img alt="" src="https://i.stack.imgur.com/EKRTj.jpg"></div>
    <div ><img alt="" src="https://i.stack.imgur.com/EKRTj.jpg"></div>
  </div>
</div>

Any help will be great. Thanks

CodePudding user response:

I suggest putting items in a line and then starting each animation with a delay:

.slider-area h2 {
  text-align: center;
  font-size: 60px;
  font-weight: 500;
  letter-spacing: 2px;
  margin: 100px 0 30px 0;
  color: rgb(0, 0, 0);
}

.wrapper {
  position: relative;
  width: 800px;
  height: 150px;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid black;
}

.wrapper div {
  position: absolute;
  padding: 20px;
  animation: slider 12s infinite linear;
}

.wrapper div:nth-child(1) {
  left: 100%;
  animation-delay: -12s;
}

.wrapper div:nth-child(2) {
  left: 100%;
  animation-delay: -10s;
}

.wrapper div:nth-child(3) {
  left: 100%;
  animation-delay: -8s;
}

.wrapper div:nth-child(4) {
  left: 100%;
  animation-delay: -6s;
}

.wrapper div:nth-child(5) {
  left: 100%;
  animation-delay: -4s;
}

.wrapper div:nth-child(6) {
  left: 100%;
  animation-delay: -2s;
}

@keyframes slider {
  0%{
    left: 100%;
    visibility: visible;
  }
  99% {
    left: -150px;
    visibility: hidden;
  }
  100% {
    left: 100%;
    visibility: hidden;
  }
}
<div >
      <h2>My Tools</h2>
      <div >
        <div >
          <img alt="" src="https://i.stack.imgur.com/EKRTj.jpg" />
        </div>
        <div >
          <img alt="" src="https://i.stack.imgur.com/EKRTj.jpg" />
        </div>
        <div >
          <img alt="" src="https://i.stack.imgur.com/EKRTj.jpg" />
        </div>
        <div >
          <img alt="" src="https://i.stack.imgur.com/EKRTj.jpg" />
        </div>
        <div >
          <img alt="" src="https://i.stack.imgur.com/EKRTj.jpg" />
        </div>
        <div >
          <img alt="" src="https://i.stack.imgur.com/EKRTj.jpg" />
        </div>
      </div>
    </div>

To slow down or speed up animation just modify animation-duration animation: slider 12s infinite linear; and then change animation-delay (NOTICE that sum of animating delays should be equal to animation-duration (here they are 12s and -12s)

To change the space between items modify the percentage of @keyframes (here it is 99%)

  • Related