简体   繁体   中英

Creating a container for the Bootstrap Carousel

I've been messing around with the bootstrap carousel. But I have been stuck on this problem. I want to get the carousel contained within a div with the next/previous buttons fixed on this outside div. And the pictures that are put in the carousel are shifted in size to match the containers size.

<div id="carouselExampleIndicators" class="carousel slide" data-interval="false">
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img class="d-block w-100" src="pic1.jpg" alt="Missing Picture 1">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="pic2.jpg" alt="Missing Picture 2">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="pic3.jpg" alt="Missing Picture 3">
    </div>
  </div>
  <a class="carousel-control-prev" href="#carouselExampleIndicators" 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="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

Im confused as all hell i've tried to create a div to hold it but the data sliders glitch out aswell as the flex the container is wrapped in.

You can push them below the slider

.carousel-indicators {
  bottom:-50px;
}

Leave space below the carousel so that the pushed indicators don't interfere with content below the slider

.carousel-inner {
   margin-bottom:50px;
}

Bootply Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM