html - 使用 Bootstrap 并使用 Carousel

标签 html css twitter-bootstrap

我正在使用 Bootstrap 并使用 Carousel 来显示一些图片。我已经准备就绪,并且显示了第一张图片,但是当您单击右侧和左侧的 Chevron 时,它不会将您带到下一张照片。

我对 HTML/CSSl 和 Bootstrap 有点陌生。感谢您的帮助。

谢谢。我的轮播代码如下。

 <div class="container-fluid">
      <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="img/type.jpg" alt="typewriter">
      <div class="carousel-caption">
        <h3>The Header</h3>
        <p>Header Text</p>
      </div>
    </div>
    <div class="item">
      <img src="img/pad.jpg" alt="scratchpad">
      <div class="carousel-caption">
        <h3>Second Header</h3>
        <p>Second Text</p>
      </div>
    </div>
    <div class="item">
      <img src="img/screen.jpg" alt="monitor">
      <div class="carousel-caption">
        <h3>Third Header</h3>
        <p>Third Text</p>
      </div>
    </div>
  </div>

  <!-- Controls -->
  <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>
    </div>

最佳答案

您可能忘记了 bootstrap js 文件。你也可以包括你的标题吗?

确保您有指向 bootstrap js 的链接(以及 css )在 html header 中

来自bootstrap site :

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

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

关于html - 使用 Bootstrap 并使用 Carousel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33006202/

相关文章:

html - wordpress 生成的 css 未被应用

css - 选择类(class)第一和第二名

html - !default css font-family 特异性标签

html - 在 Edge 浏览器上,如何使用 CSS 更改输入占位符文本颜色?

javascript - 动态创建时 Bootstrap 崩溃不起作用

html - 自定义 <select> 和 <option> 元素

html - 日期标题重叠帖子标题

html - 有没有办法让html元素的title属性显示更长时间?

javascript - Bootstrap 的 JavaScript 需要 jQuery 而 jQuery 已经加载

html - Bootstrap 折叠导航栏 - 我希望菜单左对齐但它右对齐