Twitter Bootstrap全屏旋转木马

时间:2013-11-07 18:19:05

标签: css twitter-bootstrap

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

<!---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>

1 个答案:

答案 0 :(得分: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/