Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto stretch image with bootstrap

I have a 1905px wide image and I was hoping to make it auto resize to fit the width read by bootstrap. This doesn't seem to work :

<div class="body container-fluid">
    <div class="row">
        <div class="col-md-12 col-lg-12 col-sm-12">
            <img src="~/Content/Images/Temp/WP_20140326_001.jpg" />
        </div>
    </div>
</div>

Do I have to use css width ? Thank you !

like image 993
mishap Avatar asked Nov 27 '22 20:11

mishap


2 Answers

Bootstrap has a helper class to help images to be responsive:

.img-responsive

Which, entails practically the same as Ken's answer:

.img-responsive,
.thumbnail > img,
.thumbnail a > img,
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
  display: block;
  max-width: 100%;
  height: auto;
}

Bootstrap Github .img-responsive

like image 97
MackieeE Avatar answered Dec 09 '22 19:12

MackieeE


.row > div > img { width: 100%; display: block; }
like image 35
Ken Wheeler Avatar answered Dec 09 '22 18:12

Ken Wheeler