Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 4 carousel not responsive images

Look at this: http://www.consultacultura.it/portale_comunale_della_cultura.asp?IDcomune=1

Carousel images are not responsive like images under of it. They have the same class img-fluid.

like image 290
Sergio Avatar asked Jan 16 '17 15:01

Sergio


People also ask

Why carousel is not responsive?

It seems that the bootstrap carousel images are being given a height/width attribute by views or bootstrap_views. This means that when the page is resized, or indeed viewed on a smaller screen/device the image is cut off as the carousel "window" is shrunk.

How do I make a carousel image responsive?

1. Set some height and width as per your wish in your custom css file. 2. And set img-responsive in your code in the mail HTML Page for carousel items.


2 Answers

This is a known issue in Bootstrap 4 Alpha 6...

https://github.com/twbs/bootstrap/issues/21611

As a workaround you can use..

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

http://www.codeply.com/go/0QUU06MiIL

like image 199
Zim Avatar answered Oct 27 '22 09:10

Zim


For me that workaround did not work for both, desktops and mobiles. I adjusted the proposed workaround a bit to make it -orientation- sensible.

@media (orientation: portrait) { 
    .carousel-item.active,
    .carousel-item-next,
    .carousel-item-prev {
        display: block;
        width:100%;
        height:auto;
    }
}

@media (orientation: landscape) { 
    .carousel-item.active,
    .carousel-item-next,
    .carousel-item-prev {
        display: block;
        width:100%;
        height:96vh;
    }
}
like image 24
ben Thijssen Avatar answered Oct 27 '22 08:10

ben Thijssen