I’m using the current Bootstrap Card from their documentation:
<div class="card" style="width: 20rem;">
<img class="card-img-top" src="/img/drum-kit-min.png">
<div class="card-block">
<h4>Card title</h4>
<p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#">Go somewhere</a>
</div>
</div>
But when adding my image it overflows the card container like so:
I’ve tried changing the size of the image but to no avail:
.card-img-to {
width: 10px;
}
I also have tried adding the bootstrap image-responsive
class to it. Is there any way to get this image responsive to the card, or do I have to photoshop the image?
3
Answers
try giving
max-width:100%;
to imgor add
img-responsive
class to img tagYour CSS class is incorrect. You are using
.card-img-top
in the HTML, and.card-img-to
in your stylesheet. You’ll need to add the missingt
. Since you are controlling the width of the parent.card
, you can set the image towidth:100%
.Modify your HTML code
Or you can put the image as background of .card
CSS
HTML