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

标签 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>

最佳答案

您不需要顶级 JavaScript,但您确实需要加载 Bootstrap Javascript 文件。最好在

之前
</body>

标签。

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

对你来说,我认为它是 dist/js/bootstrap.min.js

关于javascript - Bootstrap Carousel 在 Bootply 中工作,而不是在浏览器中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27696781/

相关文章:

javascript - 从电话号码中去掉最后一个连字符 (-)

javascript - 在js中提交表单时从响应正文中删除前缀

javascript - 如何使用带有 webpack 的 npm install 来使用 normalize.css?

javascript - 使用无法按预期工作的 JavaScript 切换特定文本

css - 将样式应用于 xml 属性值

javascript - 在 javascript 对象定义中连接字符串

javascript - 如果数组不包含字符串

javascript - 在匹配单词后使用正则表达式获取字符串?

html - 制成超链接时列表元素堆叠

javascript - 从 map 上删除特定标记?