我正在使用 bootstrap 并使用 flex 进行布局。
目前按钮正在占用容器的高度。文本下方有很多空间,我想删除 i ,当我向按钮添加填充时,它的大小变得不均匀。我试图通过行高调整大小,但我试图找到实际的解决方案以及我遇到这个问题的原因。
我在这里缺少任何关于 flex 的东西还是其他东西?任何帮助将不胜感激。谢谢。
.vessel-card {
display: flex;
flex-direction: column;
}
.vessel-card h3 {
margin: 0;
padding: 20px 0;
}
.departure-card {
display: flex;
padding: 20px 0;
border-top: 2px solid #888;
}
.departure-card p {
margin-right: 10px;
}
.departure-card:last-child {
border-bottom: 2px solid #888;
}
.departure-card .btn-explore {
border: 1px solid #000;
display: inline-block;
text-transform: uppercase;
color: #000;
border-radius: 0;
}
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-4 vessel-card">
<a href="cienfuegos-from-havana.html" class="special-departure">
<img src="http://placehold.it/350x150">
</a>
<h3>Vessel: Panorama</h3>
<div class="departure-card">
<p>Havana to Cienfuegos starting at $5,999</p>
<a href="#" class="btn btn-explore">Explore</a>
</div>
<div class="departure-card">
<p>Havana to Cienfuegos starting at $5,999</p>
<a href="cienfuegos-from-havana.html" class="btn btn-explore">Explore</a>
</div>
</div>
</div>
</div>
原文由 vikrantnegi 发布,翻译遵循 CC BY-SA 4.0 许可协议
Flexbox make items same
height
as you can see hereDemo
, but you can usealign-items
to change that or in your caseDemo