我应该如何将轮播指示符点更改为缩略图图像?

时间:2013-11-04 11:20:15

标签: jquery twitter-bootstrap

 <ol class="carousel-indicators">
 <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
 <li data-target="#carousel-example-generic" data-slide-to="1"></li>
 <li data-target="#carousel-example-generic" data-slide-to="2"></li>
 <li data-target="#carousel-example-generic" data-slide-to="3"></li>    
 <li data-target="#carousel-example-generic" data-slide-to="3"></li>    
 </ol>              

这是我目前在我的旋转木马幻灯片下面的旋转木马圆点,我发现很难将其更改为我的幻灯片图像的缩略图版本。我可以知道我的身体页面或bootstrap.js应该更改什么?

1 个答案:

答案 0 :(得分:3)

您可以使用jQuery在轮播幻灯片时更新一行缩略图,而不是更改现有的carousel-indicators

演示:http://bootply.com/79859

<div class="container">

    <!-- thumb navigation carousel -->
    <div class="col-md-12 hidden-sm hidden-xs" id="slider-thumbs">

        <!-- thumb navigation carousel items -->
        <ul class="list-inline">
            <li>
                <a id="carousel-selector-0" class="selected">
                    <img src="http://placehold.it/80x60&amp;text=one" class="img-responsive">
                </a>
            </li>
            <li>
                <a id="carousel-selector-1">
                    <img src="http://placehold.it/80x60&amp;text=two" class="img-responsive">
                </a>
            </li>
            <li>
                <a id="carousel-selector-2">
                    <img src="http://placehold.it/80x60&amp;text=three" class="img-responsive">
                </a>
            </li>
            <li>
                <a id="carousel-selector-3">
                    <img src="http://placehold.it/80x60&amp;text=four" class="img-responsive">
                </a>
            </li>
            <li>
                <a id="carousel-selector-4">
                    <img src="http://placehold.it/80x60&amp;text=five" class="img-responsive">
                </a>
            </li>
            <li>
                <a id="carousel-selector-5">
                    <img src="http://placehold.it/80x60&amp;text=six" class="img-responsive">
                </a>
            </li>
            ... more thumbnails
        </ul>

    </div>


    <!-- main slider carousel -->
    <div class="row">
        <div class="col-md-12" id="slider">

            <div class="col-md-12" id="carousel-bounding-box">
                <div id="myCarousel" class="carousel slide">
                    <!-- main slider carousel items -->
                    <div class="carousel-inner">
                        <div class="active item" data-slide-number="0">
                            <img src="http://placehold.it/1200x480&amp;text=one" class="img-responsive">
                        </div>
                        <div class="item" data-slide-number="1">
                            <img src="http://placehold.it/1200x480/888/FFF" class="img-responsive">
                        </div>
                        <div class="item" data-slide-number="2">
                            <img src="http://placehold.it/1200x480&amp;text=three" class="img-responsive">
                        </div>
                        <div class="item" data-slide-number="3">
                            <img src="http://placehold.it/1200x480&amp;text=four" class="img-responsive">
                        </div>
                        <div class="item" data-slide-number="4">
                            <img src="http://placehold.it/1200x480&amp;text=five" class="img-responsive">
                        </div>
                        ... more items
                    </div>
                    <!-- main slider carousel nav controls --><a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>

                    <a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
                </div>
            </div>

        </div>
    </div>
    <!--/main slider carousel-->
</div>

可以使用data-slide-to属性简化JS,而不是使用jQuery click事件: http://www.bootply.com/JiuFTQf9rI