Html Bootstrap - 包装bootstrap轮播以适合所呈现的图像

时间:2014-11-22 20:11:12

标签: html5 css3 twitter-bootstrap-3 carousel

所以,我在尝试使用bootstrap示例时遇到了问题。

我已经从bootstrap的页面复制了一个轮播示例,并尝试在我自己的项目中使用它。

然而,如图所示 - My attempt at using carousel

旋转木马不居中,上/下按钮向左/右移动,而不是在图片上方as per bootstrap example here

我使用的代码是:

    <body role="document">

    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
the navbar on the top of the page</nav>

        <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
            <!-- Indicators -->
            <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>
            </ol>

            <!-- Wrapper for slides -->
            <div class="carousel-inner" role="listbox">
                <div class="item active">
                    <img src="http://i.imgur.com/SO9y5OH.jpg" alt="...">
                    <div class="carousel-caption">
                        1
                    </div>
                </div>
                <div class="item">
                    <img src="http://i.imgur.com/1dWsLKB.jpg" alt="...">
                    <div class="carousel-caption">
                        2
                    </div>
                </div>
                <div class="item">
                    <img src="http://i.imgur.com/GNZb3UZ.jpg" alt="...">
                    <div class="carousel-caption">
                        3
                    </div>
                </div>


            </div>
            <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
                <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                <span class="sr-only">Previous</span>
            </a>
            <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
                <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
            </a>

        </div>



</body>

由于我不是那么精通html,你能不能告诉我,如何将整齐的东西整合到页面中?

1 个答案:

答案 0 :(得分:1)

将其包装成.container&gt; .row&gt; .col-sm-12

`<div class="container">
    <div class="row">
        <div class="col-sm-12">
            <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
              <!-- your carousel goes here -->
            </div>
        </div>
    </div>
 </div>`