Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a responsive image that also scales up in Bootstrap 3

I am currently using twitter bootstrap 3 and I am facing a problem to create a responsive image. I have used img-responsive class. But the image size is not scaling up. If I use width:100% instead of max-width:100% then it works perfectly. Where is the problem? This is my code:

    <div class="col-md-4 col-sm-4 col-xs-12 ">         <div class="product">                                <div class="product-img ">                    <img class="img-responsive" src="img/show1.png" alt="" />                 </div>              </div>      </div> 
like image 361
user2796803 Avatar asked Sep 19 '13 19:09

user2796803


People also ask

How do I make an image scale for responsive design?

To make an image responsive, you need to give a new value to its width property. Then the height of the image will adjust itself automatically. The important thing to know is that you should always use relative units for the width property like percentage, rather than absolute ones like pixels.

How do you make images responsive using Bootstrap?

To make an image responsive in Bootstrap, add a class . img-responsive to the <img> tag. This class applies max-width: 100%; and height: auto; to the image so that it scales 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 do I make an image fit in a div responsive?

Answer: Use the CSS max-width Property You can simply use the CSS max-width property to auto-resize a large image so that it can fit into a smaller width <div> container while maintaining its aspect ratio.


1 Answers

Bootstrap's responsive image class sets max-width to 100%. This limits its size, but does not force it to stretch to fill parent elements larger than the image itself. You'd have to use the width attribute to force upscaling.

http://getbootstrap.com/css/#images-responsive

like image 173
isherwood Avatar answered Sep 23 '22 21:09

isherwood