How to get images in Bootstrap’s card to be the same height/width with CSS?

Spread the love

Sometimes, we want to get images in Bootstrap’s card to be the same height/width with CSS.

In this article, we’ll look at how to get images in Bootstrap’s card to be the same height/width with CSS.

How to get images in Bootstrap’s card to be the same height/width with CSS?

To get images in Bootstrap’s card to be the same height/width with CSS, we set the height of the elements with the card-img-top class.

For instance, we write

.card-img-top {
  width: 100%;
  height: 15vw;
  object-fit: cover;
}

to select the elements with class card-img-top and set their heights to 15vw.

Conclusion

To get images in Bootstrap’s card to be the same height/width with CSS, we set the height of the elements with the card-img-top class.

Leave a Reply

Your email address will not be published. Required fields are marked *