Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap 4 img-fluid does not change image height

Responsive Images in Bootstrap 4, with class .img-fluid are resized disproportionally. They keep it's height even width is shrinking down correctly. That is deforming whole image. Is there any way how to make it as smooth as it was in Bootstrap 3 with class .img-responsive? Thanks

<div class="col-sm-6">     <img class="img-fluid" src="/assets/blogs/14853991244821.jpg" alt=""> </div> 

By the way it is same in Bootstrap 4 documentation (https://v4-alpha.getbootstrap.com/content/images/) where sample svg image keeps height 250 pixels regardless of it's width.

like image 916
Igor Mizak Avatar asked Jan 26 '17 09:01

Igor Mizak


People also ask

Why is IMG-fluid not working?

img-fluid may not work and how to fix it. Despite adding the class img-fluid, you may still find your website images not being responsive. The most common cause for this to happen is bootstrap versions conflict.

How do I change the height of an image in Bootstrap?

Images in Bootstrap are made responsive with . img-fluid . max-width: 100%; and height: auto; are applied to the image so that it scales with the parent element.

How do I change the size of an image in Bootstrap 4?

how to stretch image in size using bootstrap. you have to set the width of image to 100%, for that you can use Bootstrap class "w-100". keep in mind that "container-fluid" and "col-12" class sets left and right padding to 15px and "row" class sets left and right margin to "-15px" by default. make sure to set them to 0.

What does IMG-fluid do in Bootstrap?

Images in Bootstrap are made responsive with . img-fluid . This applies max-width: 100%; and height: auto; to the image so that it scales with the parent element.


1 Answers

The problem was I wrapped image in div with class .row which have display property set to flex. once removed this class from parent div image working as expected

like image 185
Igor Mizak Avatar answered Sep 21 '22 18:09

Igor Mizak