【问题标题】:Bootstrap Carousel working in Bootply, not in browserBootstrap Carousel 在 Bootply 中工作,而不是在浏览器中
【发布时间】:2014-12-29 22:09:50
【问题描述】:

因此,当我在 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 html css twitter-bootstrap carousel


    【解决方案1】:

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

    之前
    </body>
    

    标签。

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

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

    【讨论】:

    • 这看起来不错,这就是我的 js 文件所在的位置 - 但它仍然没有任何想法?
    • 这是一个 JFiddle jsfiddle.net/b74fzmc3,它不起作用,还有一个 bootply,它起作用 bootply.com/JfZZaUYBAx
    【解决方案2】:

    您不包括 bootstrap.js。

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

    【讨论】:

      猜你喜欢
      • 2023-03-15
      • 2014-10-09
      • 1970-01-01
      • 2015-11-20
      • 2015-08-10
      • 1970-01-01
      • 1970-01-01
      • 2021-10-18
      • 2021-12-22
      相关资源
      最近更新 更多