如何使用 bootstrap 将图像设置为相同高度?
How to set image in same height using bootstrap?
我试图为所有卡片放置相同大小的图像,但有些图像的高度已经很小,我该如何解决?
<div class="row">
<div class="col">
<div class="card h-100" style="width: 18rem;">
<img class="card-img-top" src="/assets/prewedding/pic1.jpg">
</div>
</div>
<div class="col">
<div class="card h-100" style="width: 18rem;">
<img class="card-img-top" src="/assets/prewedding/pic2.jpg">
</div>
</div>
</div>
你只需要设置img
来覆盖容器,比如
.card > img {
width: 100%;
height: 100%;
}
<div class="row">
<div class="col">
<div class="card h-100" style="width: 18rem;">
<img class="card-img-top" src="/assets/prewedding/pic1.jpg">
</div>
</div>
<div class="col">
<div class="card h-100" style="width: 18rem;">
<img class="card-img-top" src="/assets/prewedding/pic2.jpg">
</div>
</div>
</div>
你只需要设置img
来覆盖容器,比如
.card > img {
width: 100%;
height: 100%;
}