Image that has card not fully aligning with one next to it我一直在尝试对齐两张水平卡片,以便图像的底部对齐在一起。这是我现在的HTML代码:
<div class="container">
<div class="row">
<div class="col">
<div class="card w-100 d-flex flex-column">
<div class="row">
<div class="col">
<div class="card-block">
<h3 class="header">More Equipment</h3>
<hr>
<p> This is some text and more text and also some more text </p>
<a href="#" class="btn btn-danger btn-sm">Read More</a>
</div>
</div>
<div class="col">
<img class="img-fluid w-100 h-100" src="images/airplane.jpeg" alt="">
</div>
</div>
</div>
</div>
<div class="col">
<div class="card w-100 d-flex flex-column">
<div class="row">
<div class="col">
<div class="card-block">
<h3 class="header">More Equipment</h3>
<hr>
<p> This is some text and more text and also some more text and more and more
</p>
<a href="#" class="btn btn-danger btn-sm">Read More</a>
</div>
</div>
<div class="col">
<img class="img-fluid w-100 h-100" src="images/Agility.jpeg" alt="">
</div>
</div>
</div>
</div>`
我的CSS代码:
.card-block {
font-size: 1.2em;
position: relative;
padding: 1em;
border-top: 1px solid rgba(34, 36, 38, .1);
box-shadow: none;
}
.card {
font-size: 1em;
overflow: hidden;
padding: 5;
border-radius: .27rem;
box-shadow: 0 1px 3px 0 #d4d4d5, 0 0 1 1px #d4d4d5;
margin-top: 25px;
}
.img {
object-fit: cover;
height: 100%;
width: 100%;
}
它看起来像什么的当前图像被张贴。我的目标是让飞机与第二张卡片图像的底部对齐。我一直在使用Bootstrap版本4。
我试过使用这个代码:
<div class="container">
<div class="row">
<div class="col-sm-6 d-flex align-items-stretch">
<div class="card">
<div class="row">
<div class="col-sm-6 d-flex align-items-stretch">
<div class="card-block">
<h3 class="header">More Equipment</h3>
<hr>
<p> This is some text and more text and also some more text </p>
<a href="#" class="btn btn-danger btn-sm">Read More</a>
</div>
</div>
<div class="col-sm-6 d-flex align-items-stretch">
<img class="img-fluid d-flex w-100" src="images/airplane.jpeg" alt="">
</div>
</div>
</div>
</div>
<div class="col-sm-6 d-flex align-items-stretch">
<div class="card">
<div class="row">
<div class="col-sm-6 d-flex align-items-stretch">
<div class="card-block">
<h3 class="header">More Equipment</h3>
<hr>
<p> This is some text and more text and also some more text and more and more </p>
<a href="#" class="btn btn-danger btn-sm">Read More</a>
</div>
</div>
<div class="col-sm-6 d-flex align-items-stretch">
<img class="img-fluid d-flex w-100" src="images/Agility.jpeg" alt="">
</div>
</div>
</div>
</div>
</div>
</div>
卡片底部在这里对齐得很好,但第一张卡片中的图像并没有完全向下到底部。图片:Plane not lining up to bottom of second image
1条答案
按热度按时间iyfamqjs1#
将h-100添加到卡类下面的div类行能够解决我的问题。