将引导程序轮播添加到缩略图中

时间:2018-04-17 06:26:46

标签: html css twitter-bootstrap carousel

您好

我想知道是否有一个解决方案可以将一个引导轮播添加到给定的缩略图中,使其具有滑块(图像滑块)。

例如:

<div class = "col-sm-6 col-md-3">
          <div class = "thumbnail">
             <img src = "/bootstrap/images/kittens.jpg" alt = "Generic placeholder thumbnail">
          </div>

          <div class = "caption">
             <h3>Thumbnail label</h3>
             <p>Some sample text. Some sample text.</p>

             <p>
                <a href = "#" class = "btn btn-primary" role = "button">
                   Button
                </a> 

                <a href = "#" class = "btn btn-default" role = "button">
                   Button
                </a>
             </p>

          </div>
       </div>

    </div>

2 个答案:

答案 0 :(得分:0)

试试这个例子。  这可以使用每个轮播项目中的网格来完成。

https://www.bootply.com/81478

Carousel with Thumbnails in Bootstrap 3.0

中提及
<div id="myCarousel" class="carousel slide">
     <div class="carousel-inner">
         <div class="item active">
            <div class="row">
               <div class="col-sm-3">..
                  </div>
               <div class="col-sm-3">..
                  </div>
               <div class="col-sm-3">..
                  </div>
               <div class="col-sm-3">..
                  </div>
             </div>
             <!--/row-->
           </div>
             ...add more item(s)
         </div>
      </div>

答案 1 :(得分:0)

尝试以下代码段。添加了两个旋转木马,你可以重复这个过程

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>


<div class="container">
  <h2>Carousel Example</h2>
  <div class="row">
    <div class="col-md-6">
      <div id="myCarousel" class="carousel slide" data-ride="carousel">
        <!-- Indicators -->
        <ol class="carousel-indicators">
          <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
          <li data-target="#myCarousel" data-slide-to="1"></li>
          <li data-target="#myCarousel" data-slide-to="2"></li>
        </ol>

        <!-- Wrapper for slides -->
        <div class="carousel-inner">
          <div class="item active">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="Los Angeles" style="width:100%;">
          </div>

          <div class="item">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="Chicago" style="width:100%;">
          </div>

          <div class="item">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="New york" style="width:100%;">
          </div>
        </div>

        <!-- Left and right controls -->
        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
          <span class="glyphicon glyphicon-chevron-left"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#myCarousel" data-slide="next">
          <span class="glyphicon glyphicon-chevron-right"></span>
          <span class="sr-only">Next</span>
        </a>
      </div>
      <h3 style="text-align: center;">Test 1</h3>
    </div>

   
    <div class="col-md-6">
      <div id="myCarousel2" class="carousel slide" data-ride="carousel">
        <!-- Indicators -->
        <ol class="carousel-indicators">
          <li data-target="#myCarousel2" data-slide-to="0" class="active"></li>
          <li data-target="#myCarousel2" data-slide-to="1"></li>
          <li data-target="#myCarousel2" data-slide-to="2"></li>
        </ol>

        <!-- Wrapper for slides -->
        <div class="carousel-inner">
          <div class="item active">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="Los Angeles" style="width:100%;">
          </div>

          <div class="item">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="Chicago" style="width:100%;">
          </div>

          <div class="item">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="New york" style="width:100%;">
          </div>
        </div>

        <!-- Left and right controls -->
        <a class="left carousel-control" href="#myCarousel2" data-slide="prev">
          <span class="glyphicon glyphicon-chevron-left"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#myCarousel2" data-slide="next">
          <span class="glyphicon glyphicon-chevron-right"></span>
          <span class="sr-only">Next</span>
        </a>
      </div>
      <h3 style="text-align: center;">Test 2</h3>
    </div>
  </div>
</div>

<div class="container">

  <div class="row">
    <div class="col-md-6">
      <div id="myCarousel3" class="carousel slide" data-ride="carousel">
        <!-- Indicators -->
        <ol class="carousel-indicators">
          <li data-target="#myCarousel3" data-slide-to="0" class="active"></li>
          <li data-target="#myCarousel3" data-slide-to="1"></li>
          <li data-target="#myCarousel3" data-slide-to="2"></li>
        </ol>

        <!-- Wrapper for slides -->
        <div class="carousel-inner">
          <div class="item active">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="Los Angeles" style="width:100%;">
          </div>

          <div class="item">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="Chicago" style="width:100%;">
          </div>

          <div class="item">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="New york" style="width:100%;">
          </div>
        </div>

        <!-- Left and right controls -->
        <a class="left carousel-control" href="#myCarousel3" data-slide="prev">
          <span class="glyphicon glyphicon-chevron-left"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#myCarousel3" data-slide="next">
          <span class="glyphicon glyphicon-chevron-right"></span>
          <span class="sr-only">Next</span>
        </a>
      </div>
      <h3 style="text-align: center;">Test 3</h3>
    </div>

 
    <div class="col-md-6">
      <div id="myCarousel4" class="carousel slide" data-ride="carousel">
        <!-- Indicators -->
        <ol class="carousel-indicators">
          <li data-target="#myCarousel4" data-slide-to="0" class="active"></li>
          <li data-target="#myCarousel4" data-slide-to="1"></li>
          <li data-target="#myCarousel4" data-slide-to="2"></li>
        </ol>

        <!-- Wrapper for slides -->
        <div class="carousel-inner">
          <div class="item active">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="Los Angeles" style="width:100%;">
          </div>

          <div class="item">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="Chicago" style="width:100%;">
          </div>

          <div class="item">
            <img src="http://imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample/sample4_l.jpg" alt="New york" style="width:100%;">
          </div>
        </div>

        <!-- Left and right controls -->
        <a class="left carousel-control" href="#myCarousel4" data-slide="prev">
          <span class="glyphicon glyphicon-chevron-left"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#myCarousel4" data-slide="next">
          <span class="glyphicon glyphicon-chevron-right"></span>
          <span class="sr-only">Next</span>
        </a>
      </div>
      <h3 style="text-align: center;">Test 4</h3>
    </div>
  </div>
  </div>