1

I am using Twitter Bootstrap and creating a row with 3 images, I would like all three images in the row to become equal size, however the third image is larger than the other and it being a little large in size despite all of the columns becoming the same size.

<div class="row">
    <div class="col-6">
        <div class="card card-size h-100" style="background-color: transparent; border: 0;">
            <img src="utilities/java-icon.svg" class="card-img-top">
            <div class="card-body text-center">
                <p class="card-text"> <b> Python </b></p>
            </div>
        </div>
    </div>

    <div class="col-6">
        <div class="card card-size h-100" style="background-color: transparent; border: 0;">
            <img src="utilities/c-logo.svg" class="card-img-top">
            <div class="card-body text-center">
                <p class="card-text"> <b> Python </b></p>
            </div>
        </div>
    </div>
</div>

The code is above.

How can I secure that all of the images in the row are of equal size? I go not mind if all images are the same size as the smallest image or the largest, I would like dynamic behaviour this means I do not want to hard card a height etc...

J.Doe
  • 173
  • 1
  • 7

2 Answers2

0

In your image tag add this class to make your image responsive and equal to the columns width

If you are using Bootstrap 3 then img-responsive:

<img src="utilities/c-logo.svg" class="card-img-top img-responsive">

If You are using Bootstrap 4 then img-fluid:

<img src="utilities/c-logo.svg" class="card-img-top img-fluid">
Khalid Khan
  • 3,017
  • 1
  • 11
  • 27
0

this will work:

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
  <style>
    .myimage{
    width: 100%;
    height: 100%;
    }
  </style>
</head>

<body>

<div class="container-fluid">
  <div class="row">
    <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4" class="img-fluid">
      <img src="2.jpg"  class="myimage img-responsive thumbnail" >
    </div>  
    <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4" class="img-fluid">
      <img src="2.jpg"  class="myimage img-responsive thumbnail" >
    </div>
    <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4" class="img-fluid">
      <img src="2.jpg"  class="myimage img-responsive thumbnail" >
    </div>
  </div>
</div>

</body>

</html>

check fiddle:https://jsfiddle.net/13jqeywb/2/

Nikhil S
  • 3,786
  • 4
  • 18
  • 32