您可以取消设置
.card
的border类,并将border赋给
.card-body
而不是的类。
.card { border: unset !important; }
.card-body { border: 1px solid rgba(0,0,0,.125); border-radius: 0 0 .25rem .25rem; }
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container pt-5 px-5">
<div class="card-deck">
<div class="card bg-light">
<img class="card-img-top" src="https://via.placeholder.com/500x180/095865/000000">
<div class="card-body text-center">
<h2 class="card-title">Lorem ipsum</h2>
<p class="card-text">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
</p>
</div>
</div>
<div class="card bg-light">
<img class="card-img-top" src="https://via.placeholder.com/500x180/095865/000000">
<div class="card-body text-center">
<h2 class="card-title">Lorem ipsum</h2>
<p class="card-text">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
</p>
</div>
</div>
</div>
</div>