【发布时间】:2021-03-06 05:18:50
【问题描述】:
我正在使用 flex 来包含使用引导程序的卡片,但卡片未显示为屏幕的整个宽度。它们堆叠在屏幕的左半边。
HTML 文件是这样的:
<section class="projects" id="projects">
<div class="services-cards">
<div class="card" style="width: 14rem;">
<img class="card-img-top" src="images/undraw_develop_app_re_bi4i.svg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of
the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
<div class="card" style="width: 14rem;">
<img class="card-img-top" src="images/undraw_for_review_eqxk.svg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of
the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
<div class="card" style="width: 14rem;">
<img class="card-img-top" src="images/undraw_Success_factors_re_ce93.svg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of
the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
</section>
css 是这样的
.card{
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
padding:10px;
}
.services-cards{
display: flex;
flex-direction: row;
margin-top: 20px;
margin-left:30px;
margin-bottom: 90px;
justify-items:auto;
}
我做错了什么?我希望弯曲的内容(在这种情况下为卡片)将是屏幕的全宽。
现在是这样的
【问题讨论】:
-
你想让
.card全屏吗? -
.service-cards 为全屏宽度如您所见,我在服务卡中有 3 张卡。我希望将这 3 张卡片均匀地分布在屏幕的宽度上。现在,它们在屏幕的左半边彼此相邻。
-
根据需要添加
.services-cards:{justify-content:space-around}或justify-content:space-between
标签: html css bootstrap-4