Bootstrap轮播指示器循环问题

时间:2015-07-10 01:07:53

标签: twitter-bootstrap twitter-bootstrap-3 carousel

我已将我的Bootstrap轮播指示灯从单选按钮更改为小预览缩略图,这导致缩略图在骑行时变得混乱。

不幸的是,我根本不了解Bootstrap的默认轮播循环,所以我无法弄清楚我的主动指示缩略图如何取代其他缩略图。

如果有人可以帮我解决这个问题(和/或解释默认的主动指示器循环),我真的很感激帮助!

HTML:     

    <ol class="carousel-indicators">
        <li data-target="#homeWineCarousel" data-slide-to="0" class="active">
            <img src="http://taybehwinery.com/images/wine/blanc14.jpg">
        </li>
        <li data-target="#homeWineCarousel" data-slide-to="1">
            <img src="http://taybehwinery.com/images/wine/cabernet13.jpg">
        </li>
        <li data-target="#homeWineCarousel" data-slide-to="2">
            <img src="http://taybehwinery.com/images/wine/merlot13.jpg">
        </li>
        <li data-target="#homeWineCarousel" data-slide-to="3">
            <img src="http://taybehwinery.com/images/wine/syrah13.jpg">
        </li>
    </ol>

    <div class="carousel-inner">
        <div class="item active">
            <a href="blanc14.html"><img src="http://taybehwinery.com/images/wine/blanc14.jpg"></a>
            <div class="carousel-caption"><h3><a href="blanc14.html">Sauvignon Blanc 2014</a></h3></div>
        </div>
        <div class="item">
            <a href="cabernet13.html"><img src="images/wine/cabernet13.jpg"></a>
            <div class="carousel-caption"><h3><a href="cabernet13.html">Cabernet Sauvignon 2013</a></h3></div>
        </div>
        <div class="item">
            <a href="merlot13.html"><img src="images/wine/merlot13.jpg"></a>
            <div class="carousel-caption"><h3><a href="merlot13.html">Merlot 2013</a></h3></div>
        </div>
        <div class="item">
            <a href="syrah13.html"><img src="images/wine/syrah13.jpg"></a>
            <div class="carousel-caption"><h3><a href="syrah13.html">Syrah 2013</a></h3></div>
        </div>
    </div>

    <a class="left carousel-control" href="#homeWineCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left"></span>
    </a>
    <a class="right carousel-control" href="#homeWineCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right"></span>
    </a>
</div>

CSS:

.carousel-indicators li img { 
    display: block; 
    width: 120px; height: auto; 
}
.carousel-indicators {
    position: absolute; 
    width: 100%;
    top: 630px; 
    left: 20px;
    z-index: 5;
    margin: 0;
    list-style: none;
}
.carousel-indicators .active { 
    position: relative;
    top: -230px;
    left: -75px;
}
.carousel-indicators li { 
    width: 80px; height: auto;
}

这是我第一次使用堆栈溢出,所以如果我的问题不清楚,或者您需要更多信息,请告诉我。我知道我的代码可能非常混乱,至少有点荒谬 - 我是初学者,欢迎任何有助于清理的建议。

1 个答案:

答案 0 :(得分:0)

您需要仅将<li>替换为图像,并将属性放置在图像上,使其如下所示:

<img src="http://taybehwinery.com/images/wine/merlot13.jpg" data-target="#myCarousel" data-slide-to="2"/>

我创建了JSFiddle并完成了以下任务,请查看,如果您有任何问题,我会在这里回答。

http://jsfiddle.net/tfthum3t/