I created a list of images and attempted to reduce the height of one particular image by half.
.img {
background: #255;
}
img {
max-width: 100%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col">
<div class="card">
<div class="img">
<img src="https://via.placeholder.com/800x200/009/fff.png">
</div>
<div class="card-body">
<h5 class="card-title">Image title</h5>
<p class="card-text">description text.</p>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="img">
<img src="https://via.placeholder.com/550x768/009/fff.png">
</div>
<div class="card-body">
<h5 class="card-title">Image title</h5>
<p class="card-text">description text.</p>
</div>
</div>
</div>
</div>
</div>
I utilized the transform property with scaleY(0.5) but noticed a gap between the image and text. I want to remove this space when adjusting the image height.
.img {
background: #255;
transform: scaleY(0.5);
transform-origin: top;
overflow: hidden;
}
img {
max-width: 100%;
transform: scaleY(2);
transform-origin: top;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col">
<div class="card">
<div class="img">
<img src="https://via.placeholder.com/800x200/009/fff.png">
</div>
<div class="card-body">
<h5 class="card-title">Image title</h5>
<p class="card-text">description text.</p>
</div>
</div>
</div>
<div class="col">
<div class="card">
<div class="img">
<img src="https://via.placeholder.com/550x768/009/fff.png">
</div>
<div class="card-body">
<h5 class="card-title">Image title</h5>
<p class="card-text">description text.</p>
</div>
</div>
</div>
</div>
</div>
Why is there excess blank space despite setting the image height? How can I eliminate this extra space and display only half of the image's original height?