获取模式轮播以在已选择的图像上打开

我试图让模式中的轮播在用户选择的图像上打开。我已经尝试过data-slide-to="##",但没有看到。我将在下面发布代码。我将删除重复的代码。


<!DOCTYPE html>

<html>


<head>


  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <meta name="description" content="">

  <meta name="author" content="">


  <title>Name LTD - Gallery</title>


  <!-- Bootstrap core CSS -->

  <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">


  <!-- Custom styles for this template -->

  <link href="css/shop-homepage.css" rel="stylesheet">

    <link href="css/carousel.css" rel="stylesheet" id="bootstrap-css">

    <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>

    <script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

</head>


<body>


  <!-- Navigation -->

  <nav class="navbar navbar-expand-lg navbar-dark bg-secondary fixed-top">

    <div class="container">

      <a class="navbar-brand" href="index.php">Name</a>

      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">

        <span class="navbar-toggler-icon"></span>

      </button>

      <div class="collapse navbar-collapse" id="navbarResponsive">

        <ul class="navbar-nav ml-auto">

          <li class="nav-item">

            <a class="nav-link" href="index.php">Home</a>

          </li>

          <li class="nav-item">

            <a class="nav-link" href="#">About</a>

          </li>

          <li class="nav-item active">

            <a class="nav-link" href="#">Gallery

              <span class="sr-only">(current)</span>

              </a>

          </li>

          <li class="nav-item">

            <a class="nav-link" href="contact.php">Contact</a>

          </li>

        </ul>

      </div>

    </div>

  </nav>

因此,当前当用户选择图像 1 时,图像 1 显示在轮播上,但如果选择图像 2,则图像 1 仍然首先显示,依此类推。所以我想要的是用户能够选择图像 3 和图像 3在轮播中被选择,这样他们就不必滚动轮播才能到达它。


慕码人8056858
浏览 85回答 1
1回答

料青山看我应如是

您还应该通过执行data-target="#carousel-example-generic"将图像指向滑块,因为您将标签仅指向模态,这就是它不更新滑块的原因,所以下面的代码可能对你有帮助<div class="row text-center text-lg-left">&nbsp; <div class="col-lg-3 col-md-4 col-6">&nbsp; &nbsp; <a href="#" class="d-block mb-4 h-100" data-toggle="modal" data-target=".imgGal">&nbsp; &nbsp; <img src="img/img14.png" class="img-fluid img-thumbnail" data-target="#carousel-example-generic" data-slide-to="0">&nbsp; &nbsp; </a>&nbsp; </div>&nbsp; <div class="col-lg-3 col-md-4 col-6">&nbsp; &nbsp; <a href="#" class="d-block mb-4 h-100" data-toggle="modal" data-target=".imgGal">&nbsp; &nbsp; <img src="img/img15.png" class="img-fluid img-thumbnail" data-target="#carousel-example-generic" data-slide-to="1">&nbsp; &nbsp; </a>&nbsp; </div>&nbsp; <div class="col-lg-3 col-md-4 col-6">&nbsp; &nbsp; <a href="#" class="d-block mb-4 h-100" data-toggle="modal" data-target=".imgGal">&nbsp; &nbsp; <img src="img/img9.png" class="img-fluid img-thumbnail" data-target="#carousel-example-generic" data-slide-to="2">&nbsp; &nbsp; </a>&nbsp; </div>&nbsp; <div class="col-lg-3 col-md-4 col-6">&nbsp; &nbsp; <a href="#" class="d-block mb-4 h-100" data-toggle="modal" data-target=".imgGal">&nbsp; &nbsp; <img src="img/img10.png" class="img-fluid img-thumbnail" data-target="#carousel-example-generic" data-slide-to="3">&nbsp; &nbsp; </a>&nbsp; </div></div>
打开App,查看更多内容
随时随地看视频慕课网APP