代码之家  ›  专栏  ›  技术社区  ›  Muiter

旋转木马在更改为动态脚本后不旋转

  •  0
  • Muiter  · 技术社区  · 4 年前

    我已经将转盘的静态代码更改为动态代码。由于某些原因,转盘没有旋转图像。我已将网站联机查看: here

      <?php
      $files = glob('img/carousel/*.*');
      shuffle($files);    
      $no_files = count($files);
      ?>
    
    <header>
      <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
        <ol class="carousel-indicators">
            <?php
            for ($x = 0; $x <= $no_files; $x++)
            {
                echo '<li data-target="#carouselExampleIndicators" data-slide-to="'.$x.'" '; if($x == 0) { echo 'class="active"'; } echo'></li>';
            }
            ?>
        </ol>
        <div class="carousel-inner" role="listbox">
    
          <?php
          foreach($files as $file)
          {
              echo '<div class="carousel-item active" style="background-image: url('.$file.')">
                    <div class="carousel-caption d-none d-md-block">
                    </div>
                  </div>';
          }
          ?>
    
        </div>
        <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
          <span class="carousel-control-prev-icon" aria-hidden="true"></span>
          <span class="sr-only">Vorige</span>
        </a>
        <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
          <span class="carousel-control-next-icon" aria-hidden="true"></span>
          <span class="sr-only">Volgende</span>
        </a>
      </div>
    </header>
    
    0 回复  |  直到 4 年前
        1
  •  0
  •   Muiter    4 年前

      <?php
      $y = 0;
      foreach($files as $file)
      {
          $y++;
          echo '<div class="carousel-item'; if($y == 1) { echo ' active'; } echo'" style="background-image: url('.$file.')">
                <div class="carousel-caption d-none d-md-block">
                </div>
              </div>';
      }
      ?>