使用 CSS-HTML 的幻灯片仅显示四张幻灯片

Slideshow using CSS-HTML only showing four slides

我正在使用幻灯片,我只使用 css 和 HTML。我总共使用了六张幻灯片,但它只显示了四张幻灯片。它不会移动到第 5 位和第 6 位。我不明白我在哪里犯了错误,请纠正我。

问题:https://jsfiddle.net/usm10hfy/

你可以在 JsFiddle 上看到我面临的问题。希望你帮忙,提前致谢。

<style>
body {
  font-family: Helvetica, sans-serif;
  padding: 5%;
  text-align: center;
}

#slideshow {
  overflow: hidden;
  height: 510px;
  width: 728px;
  margin: 0 auto;
}

.slide-wrapper {
  width: 2912px;
  -webkit-animation: slide 18s ease infinite;
}

.slide {
  float: left;
  height: 510px;
  width: 728px;
}

.slide:nth-child(1) {
  background: #D93B65;
}

.slide:nth-child(2) {
  background: #037E8C;
}

.slide:nth-child(3) {
  background: #36BF66;
}

.slide:nth-child(4) {
  background: #D9D055;
}

.slide:nth-child(5) {
  background: #D9D055;
}

.slide:nth-child(6) {
  background: #D9D055;
}

.slide-number {
  color: #000;
  text-align: center;
  font-size: 10em;
}

@-webkit-keyframes slide {
  20% {margin-left: 0px;}
  30% {margin-left: -728px;}
  50% {margin-left: -728px;}
  60% {margin-left: -1456px;}
  70% {margin-left: -1456px;}
  80% {margin-left: -2184px;}
  90% {margin-left: -2184px;}
}
</style>

<div id="slideshow">
  <div class="slide-wrapper">
    <div class="slide"><h1 class="slide-number">1</h1></div>
    <div class="slide"><h1 class="slide-number">2</h1></div>
    <div class="slide"><h1 class="slide-number">3</h1></div>
    <div class="slide"><h1 class="slide-number">4</h1></div>
    <div class="slide"><h1 class="slide-number">5</h1></div>
    <div class="slide"><h1 class="slide-number">6</h1></div>
  </div>
</div>
body {
  font-family: Helvetica, sans-serif;
  padding: 5%;
  text-align: center;
}

#slideshow {
  overflow: hidden;
  height: 510px;
  width: 728px;
  margin: 0 auto;
}

.slide-wrapper {
  width: 4368px; /*change this width */
  -webkit-animation: slide 10s ease infinite;
}

.slide {
  float: left;
  height: 510px;
  width: 728px;
}

.slide:nth-child(1) {
  background: #D93B65;
}

.slide:nth-child(2) {
  background: #037E8C;
}

.slide:nth-child(3) {
  background: #36BF66;
}

.slide:nth-child(4) {
  background: #D9D055;
}

.slide:nth-child(5) {
  background: #D9D055;
}

.slide:nth-child(6) {
  background: #D9D055;
}

.slide-number {
  color: #000;
  text-align: center;
  font-size: 10em;
}

@-webkit-keyframes slide {  /* add keyframe animations to move each slide towards left */
  15% {margin-left: 0px;}
  30% {margin-left: -728px;}
  45% {margin-left: -1456px;}
  60% {margin-left: -2184px;}
  75%{margin-left: -2912px;}
  90%{margin-left: -3640px;}

}

现在可以正常工作了:https://jsfiddle.net/4othdxg7/

演示:

body {
  font-family: Helvetica, sans-serif;
  padding: 5%;
  text-align: center;
}

#slideshow {
  overflow: hidden;
  height: 510px;
  width: 728px;
  margin: 0 auto;
}

.slide-wrapper {
  width: 8736px;
  -webkit-animation: slide 12s ease infinite;
}

.slide {
  float: left;
  height: 510px;
  width: 728px;
}

.slide:nth-child(1) {
  background: #D93B65;
}

.slide:nth-child(2) {
  background: #037E8C;
}

.slide:nth-child(3) {
  background: #36BF66;
}

.slide:nth-child(4) {
  background: #D9D055;
}

.slide:nth-child(5) {
  background: red;
}

.slide:nth-child(6) {
  background: #D9D055;
}

.slide:nth-child(7) {
  background: #D93B65;
}

.slide:nth-child(8) {
  background: #037E8C;
}

.slide:nth-child(9) {
  background: #36BF66;
}

.slide:nth-child(10) {
  background: #D9D055;
}

.slide:nth-child(11) {
  background: red;
}

.slide:nth-child(12) {
  background: #D9D055;
}

.slide-number {
  color: #000;
  text-align: center;
  font-size: 10em;
}

@-webkit-keyframes slide {
  8% {
    margin-left: 0px;
  }
  16% {
    margin-left: -728px;
  }
  24% {
    margin-left: -1456px;
  }
  32% {
    margin-left: -2184px;
  }
  40% {
    margin-left: -2912px;
  }
  48% {
    margin-left: -3640px;
  }
  56% {
    margin-left: -4368px;
  }
  64% {
    margin-left: -5096px;
  }
  72% {
    margin-left: -5824px;
  }
  80% {
    margin-left: -6552px;
  }
  88% {
    margin-left: -7280px;
  }
  100% {
    margin-left: -8008px;
  }
}
<div id="slideshow">
  <div class="slide-wrapper">
    <div class="slide">
      <h1 class="slide-number">1</h1>
    </div>
    <div class="slide">
      <h1 class="slide-number">2</h1>
    </div>
    <div class="slide">
      <h1 class="slide-number">3</h1>
    </div>
    <div class="slide">
      <h1 class="slide-number">4</h1>
    </div>
    <div class="slide">
      <h1 class="slide-number">5</h1>
    </div>
    <div class="slide">
      <h1 class="slide-number">6</h1>
    </div>
    <div class="slide">
      <h1 class="slide-number">7</h1>
    </div>

    <div class="slide">
      <h1 class="slide-number">8</h1>
    </div>
    <div class="slide">
      <h1 class="slide-number">9</h1>
    </div>
    <div class="slide">
      <h1 class="slide-number">10</h1>
    </div>
    <div class="slide">
      <h1 class="slide-number">11</h1>
    </div>
    <div class="slide">
      <h1 class="slide-number">12</h1>
    </div>

  </div>
</div>