Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap: img-responsive vs img-fluid

I am using bootstrap 3.3.6 and I am using class img-responsive for image responsiveness.

I have found a new class name img-fluid, but it's not present in 3.3.6 version.

Can anyone tell what is the difference between img-responsive and img-fluid?

img-responsive just resizes the image as per parent container size which we can achive it using css property width: 100% and height: auto. Then why to use imag-responsive class?

like image 883
Jay Avatar asked May 31 '16 14:05

Jay


People also ask

What is IMG-fluid in Bootstrap?

In Bootstrap 4 you would use the . img-fluid class on all images you would like to be responsive. This class tells the browser not to expand the image larger than its original size using a max-width. And it also tells it to scale down the image if the browser window gets narrower than the image pixel width.

What is IMG-responsive?

.img-responsive. Makes an image responsive (will scale nicely to the parent element)

Which class will you use to create a responsive image that changes its width based on the browser width?

Create responsive images by adding an . img-responsive class to the <img> tag. The image will then scale nicely to the parent element.

How can make responsive Div in Bootstrap?

Every one of those four Bootstrap Grid types becomes responsive only if you assign to it its own designated CSS class. For example, to make a div responsive for extra small devices, the div must have its own Bootstrap . col-xs-<number_of_columns_to_take> class, like <div class=”col-xs-6″>.


1 Answers

img-responsive was in Bootstrap 3, img-fluid is in Bootstrap 4 since beta version.

Removes display: block; from .img-fluid. Responsive image behavior is not dependent on display: block;, so we can safely remove it on our end. Should you need block level, you can easily override that in the source or with a utility class.

.img-fluid {
  max-width: 100%;
  height: auto;
}
.img-responsive {
  display: block;
  max-width: 100%;
  height: auto;
}
like image 156
max Avatar answered Sep 21 '22 11:09

max