Bootstrap carousel image size

2019-07-21 17:42发布

Hi have a responsive problem in the sizing of a carousel images, 7 of them are in horizontal size (1800x1200) but one - the last - is in vertical and I can't code it propertly to have it responsive:

https://www.luismatera.art/refugio.html

Code for carousel is:

            <div class="row">
                <div class="col-md-1 hidden-xs"></div>
                <div class="col-md-10 col-xs-12 col-sm-12">
                
                <div id="carouselExampleControls" class="carousel slide carousel-fade" data-ride="carousel" data-interval="10000">
                  <div class="carousel-inner">
                    <div class="carousel-item active">
                      <img src="img/refugio/01.jpg" class="d-block w-100" alt="...">
                    </div>
                    <div class="carousel-item">
                      <img src="img/refugio/02.jpg" class="d-block w-100" alt="...">
                    </div>
                    <div class="carousel-item">
                      <img src="img/refugio/03.jpg" class="d-block w-100" alt="...">
                    </div>                    
                    <div class="carousel-item">
                      <img src="img/refugio/04.jpg" class="d-block w-100" alt="...">
                    </div>
                    <div class="carousel-item">
                      <img src="img/refugio/05.jpg" class="d-block w-100" alt="...">
                    </div>
                    <div class="carousel-item">
                      <img src="img/refugio/06.jpg" class="d-block w-100" alt="...">
                    </div>
                    <div class="carousel-item">
                      <img src="img/refugio/07.jpg" class="d-block w-100" alt="...">
                    </div>
					<div class="carousel-item" align="center">
                      <img src="img/refugio/08.jpg" class="d-block img-fluid" alt="...">
                    </div>		


                  </div>
                  <a class="carousel-control-prev" href="#carouselExampleControls" 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="#carouselExampleControls" role="button" data-slide="next">
                    <span class="carousel-control-next-icon" aria-hidden="true"></span>
                    <span class="sr-only">Next</span>
                  </a>
                </div>

                    <p>Proyecto abierto</p>
                    <p align="right">Asturias · 2017/18</p>
                </div>

                 <div class="col-md-1 hidden-xs"></div>

        </div>

I have replaced class="d-block w-100" with class="d-block img-fluid"

Any help will be appreciated :-)

Thanks in advance, Luis

1条回答
Ridiculous、
2楼-- · 2019-07-21 18:25
.carousel-fade .carousel-item, .carousel-item img  {
  max-height: 90vh;
}

fixes it. It simply sets the max-height of any .carousel-item to maximum 90% of viewport height, which seems to be what you're after.

Obviously, you can tweak it to whatever makes sense for your project (maybe 85vh?).

查看更多
登录 后发表回答