I'm not able to resize the carousel height. I would like that the carousel won't use image height but another height that i decide, tried different css rules but withouth success.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<section id="portfolio" class="page-section">
<div id="reviews" class="container-fluid">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://images.pexels.com/photos/2409628/pexels-photo-2409628.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="...">
<div class="carousel-caption d-none d-md-block">
<h5>Title</h5>
<p>Description</p>
</div>
</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>
</div>
There is a JSFiddle if could help. https://jsfiddle.net/6bjom57s/
Short answer:
You forgot to add img-fluid to your images. Plus, normally you should set carousel width, not height. If you want to set it's height, see Complete answer.
Complete answer:
( You can view working code here : Fiddle )
First, You should add .img-fluid to your images in carousel, if you want it to be responsive.
Second, Normally you should set width of carousel in bootstrap. it works as you can see here : Fiddle (But still it's not perfect.)
But if you want to set the height of carousel, you can change some bootstrap styles:
.carousel-item,
.carousel-inner,
.carousel-inner img {
height: 100%;
width: auto;
}
.carousel-item {
text-align: center;
}
then you can set carousel's height :
.carousel {
height: 200px;
}
You can view this here : Fiddle
This will not crop images. if you want images to cover instead (and also cropped), you can use:
.carousel-inner img {
width: 100%;
height: auto;
}
you can see it here: Fiddle
Also , you can use media queries to customize it as well.
And last, you should refrence to jquery and bootstrap.js if you didn't already.
This seems to work:
.carousel-item img {
max-height: 500px; /* input your desired height here */
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With