0

我想为我的网页制作一个全屏图像轮播,我设法让它正常工作,直到我添加了多个图像。现在图像在彼此下方,示例文本仅在最后一张图像上。这是我的代码,希望对你有所帮助。谢谢。

<!---CAROSUEL---->
<div id="myCarousel" class="carousel slide">
<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>
<div class="carousel-inner"></div>
    <div class="item active"><img src="img/bg.jpg" style="height: 100%; width: 100%; display: block;">
        <div class="container">
            <div class="carousel-caption">
            <h1>Sara Cook</h1>
            <p>This tag will contain the text in which we want to appear on our slide...</p>
            </div>
        </div>
    </div>
    <div class="item"><img src="img/bg1.jpg" style="height: 100%; width: 100%; display: block;">
        <div class="container">
            <div class="carousel-caption">
            <h1>Sara Cook</h1>
            <p>This tag will contain the text in which we want to appear on our slide...</p>
            </div>
        </div>
    </div>
    <div class="item"><img src="img/bg3.jpg" style="height: 100%; width: 100%; display: block;">
        <div class="container">
            <div class="carousel-caption">
            <h1>Sara Cook</h1>
            <p>This tag will contain the text in which we want to appear on our       slide...</p>
            </div>
        </div>
    </div>
</div> 
<a class="left carousel-control" href="myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span> 
</a>
<a class="right carousel-control" href="myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span> 
</a>
</div>
4

1 回答 1

1

.carousel-inner在打开后立即关闭 - 它应该围绕每个.item

代替:

<div class="carousel-inner"></div>

利用:

<div class="carousel-inner">

    <!-- Carousel images -->

</div> <!-- Close right before the carousel controls -->
<a class="left carousel-control" href="myCarousel" data-slide="prev">
... etc

简化示例:http: //jsfiddle.net/52VtD/486/

于 2013-11-07T18:29:53.870 回答