11

Hopfully the title and the demo say it all. The new carousel of Bootstrap 4 isn't responsive. The images are out of their aspect ratio.

Does somebody know how to solve this without doing major adjustments in the css and html?

.wrapper {
  max-width:200px;
  width:100%;
}
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="wrapper">
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
  <div class="carousel-inner" role="listbox">
    <div class="carousel-item active">
      <img class="d-block img-fluid" src="https://placehold.it/400x200" alt="First slide">
    </div>
    <div class="carousel-item">
      <img class="d-block img-fluid" src="https://placehold.it/400x200" alt="Second slide">
    </div>
    <div class="carousel-item">
      <img class="d-block img-fluid" src="https://placehold.it/400x200" alt="Third slide">
    </div>
  </div>
</div>
</div>
NiZa
  • 3,806
  • 1
  • 21
  • 29

2 Answers2

14

You do not need a wrapper or something like that. The default styling for the .active .carousel-item is display: flex.

You will need to add

.carousel-item.active,
.carousel-item-next,
.carousel-item-prev {
  display: block;
}

to your custom css.

1

Just add this bellow css,

<style>
.wrapper {
  max-width:200px;
  width:100%;
}
.carousel-item-next, .carousel-item-prev, .carousel-item.active {
    display: block !important;
}
</style>

i hope it will work fine...

Piyali
  • 506
  • 2
  • 11