小编Nic*_*one的帖子

使用 Flexbox 将特定元素居中

我在 Flexbox 中有一个包含三个元素的布局,如下所示:

.flex-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

<div class="flex-container">
  <div class="flex-item"> computed width of 50px </div>
  <div class="flex-item plz-center"> computed width of 25px </div>
  <div class="flex-item"> computed width of 150px </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我想将中间的项目居中plz-center,并将其他项目保留在两侧,如下图所示:

弯曲端

它们在弹性行中工作正常,但如果最终项目的宽度不同,则中间项目不会保持居中。我最好plz-center修复一下吗?

html css flexbox

3
推荐指数
1
解决办法
1806
查看次数

标签 统计

css ×1

flexbox ×1

html ×1