Bootstrap Carousel无法正确显示

时间:2017-06-20 23:29:37

标签: twitter-bootstrap carousel

我正在处理我的投资组合并为Bootstrap轮播粘贴了代码,但它没有正确显示。我一直在研究,但似乎无法找到这种情况发生的原因。其他轮播模板也同样出现。这看起来像CSS问题吗?

截图:

Screenshot

以下是代码:

 <!-- About Me ---------------------------------------------------------->
<section class="bg-primary" id="about">
<div class="container">
  <div class="row">
    <div class="col-lg-8 col-lg-offset-2 text-center aboutMe">
      <h2 class="section-heading">About Me</h2>
      <hr class="light">
      <p class="text-faded">I'm a full stack web developer with a passion for HTML and CSS. I love learning new languages and building from the ground up. In my spare time I enjoy being with my family and pets, traveling to Orleans, Cape Cod and avoiding doing laundry.
      </p>
    </div>
  </div>
</div>

<!---Carousel -------------------------------------------------------------->
    <div id="portfolio-Carousel" class="carousel slide" data-ride="carousel">
      <ol class="carousel-indicators">
        <li data-target="#portfolio-Carousel" data-slide-to="0" class="active"></li>
        <li data-target="#portfolio-Carousel" data-slide-to="1"></li>
        <li data-target="#portfolio-Carousel" data-slide-to="2"></li>
      </ol>
      <div class="carousel-inner" role="listbox">
        <div class="carousel-item active">
          <img class="d-block img-fluid" src="..." alt="First slide">
        </div>
        <div class="carousel-item">
          <img class="d-block img-fluid" src="..." alt="Second slide">
        </div>
        <div class="carousel-item">
          <img class="d-block img-fluid" src="..." alt="Third slide">
        </div>
      </div>
      <a class="carousel-control-prev" href="#portfolio-Carousel" role="button" data-slide="prev">
  <span class="carousel-control-prev-icon" aria-hidden="true"></span>
  <span class="sr-only">Previous</span>
</a>
      <a class="carousel-control-next" href="#portfolio-Carousel" role="button" data-slide="next">
  <span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
      </a>
</div>
</section>

1 个答案:

答案 0 :(得分:0)

您必须将carousel-item班级替换为item班级。它会对你有用。

<section class="bg-primary" id="about">
<div class="container">
  <div class="row">
    <div class="col-lg-8 col-lg-offset-2 text-center aboutMe">
      <h2 class="section-heading">About Me</h2>
      <hr class="light">
      <p class="text-faded">I'm a full stack web developer with a passion for HTML and CSS. I love learning new languages and building from the ground up. In my spare time I enjoy being with my family and pets, traveling to Orleans, Cape Cod and avoiding doing laundry.
      </p>
    </div>
  </div>
</div>

<!---Carousel -------------------------------------------------------------->
    <div id="portfolio-Carousel" class="carousel slide" data-ride="carousel">
      <ol class="carousel-indicators">
        <li data-target="#portfolio-Carousel" data-slide-to="0" class="active"></li>
        <li data-target="#portfolio-Carousel" data-slide-to="1"></li>
        <li data-target="#portfolio-Carousel" data-slide-to="2"></li>
      </ol>
      <div class="carousel-inner" role="listbox">
        <div class="item active">
          <img class="d-block img-fluid" src="..." alt="First slide">
        </div>
        <div class="item">
          <img class="d-block img-fluid" src="..." alt="Second slide">
        </div>
        <div class="item">
          <img class="d-block img-fluid" src="..." alt="Third slide">
        </div>
      </div>
      <a class="carousel-control-prev" href="#portfolio-Carousel" role="button" data-slide="prev">
  <span class="carousel-control-prev-icon" aria-hidden="true"></span>
  <span class="sr-only">Previous</span>
</a>
      <a class="carousel-control-next" href="#portfolio-Carousel" role="button" data-slide="next">
  <span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
      </a>
</div>
</section>