Bootstrap Carousel在Bootply中工作,而不是在浏览器中

时间:2014-12-29 22:09:50

标签: javascript html css twitter-bootstrap carousel

所以当我在bootply上加载html时,一切似乎都有效,但是当我将它推到我的网页(Github页面)时,轮播会加载,但不会进行任何滚动。

继续推送到网站的HTML,它在Bootply上完全相同,只是在顶部附近添加了脚本,我认为需要它才能使它工作,但它似乎没有做任何事情。显然,在Bootply上没有必要。

<head>
    <link rel="stylesheet" href="dist/css/bootstrap.css">
    <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <script>
    $(function(){
        $('#carousel-content').carousel();
    });
    </script>

<body>
    <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>

    <div class="nav">
      <p><br><br></p>
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <ul class="nav nav-pills nav-justified">
                        <li role="presentation" class="active"><a href="#">Home</a></li>
                        <li role="presentation"><a href="#">Projects</a></li>
                        <li role="presentation"><a href="#">About Me</a></li>
                        <li role="presentation"><a href="#">Contact Me</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

    <div class="potrait">
        <p><br><br></p>
        <img src = "https://lh3.googleusercontent.com/-eQB0B8kGRiw/AAAAAAAAAAI/AAAAAAAAAAA/gRPFLBygtI8/photo.jpg" class="center-block img-circle" height="200" width="200">
    </div>

    <div class="info">
        <p><br><br></p>
        <h1 class="text-center"> Matt Kowalczykowski </h1>
        <h2 class="text-center"> Mechatronics Engineering Student </h2>
        <p><br><br></p>
    </div>

    <div class="container">
        <div class="row">
            <div class="col-md-8 col-centered">
                <div id="carousel-content" class="carousel slide" data-ride="carousel">
                  <!-- Indicators -->
                  <ol class="carousel-indicators">
                    <li data-target="#carousel-content" data-slide-to="0" class="active"></li>
                    <li data-target="#carousel-content" data-slide-to="1"></li>
                    <li data-target="#carousel-content" data-slide-to="2"></li>
                  </ol>

                  <!-- Wrapper for slides -->
                  <div class="carousel-inner">
                    <div class="item active">
                      <img src="http://images.wisegeek.com/robots-assembling-car-bodies.jpg">
                      <div class="carousel-caption">
                          <h3>Mechanical</h3>
                      </div>
                    </div>
                    <div class="item">
                      <img src="http://seetech-corp.com/engineering/wp-content/uploads/2011/07/seetech-electrical-engineering-cabinets.jpg">
                      <div class="carousel-caption">
                          <h3>Electrical</h3>
                      </div>
                    </div>
                    <div class="item">
                      <img src="http://cdn.onextrapixel.com/wp-content/uploads/2013/07/clean-coding-best-practices.jpg">
                      <div class="carousel-caption">
                          <h3>Programming</h3>
                      </div>
                    </div>
                  </div>

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

2 个答案:

答案 0 :(得分:0)

您不需要顶级JavaScript,但您需要加载Bootstrap Javascript文件。

之前最好
</body>

标签

<script src="link/to/bootstrap.min.js"></script>

对你而言,我认为这将是dist / js / bootstrap.min.js

答案 1 :(得分:0)

你不包括bootstrap.js。

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>