Css 在Bootstrap中将8张大小相同的卡放在一行中

Css 在Bootstrap中将8张大小相同的卡放在一行中,css,bootstrap-4,Css,Bootstrap 4,我真的被Bootstrap中的列系统搞糊涂了。以下是我所拥有的: <div class="container-fluid"> <!-- Page Heading --> <div class="d-sm-flex align-items-center justify-content-between mb-4"> <h1 class="h3 mb-0 text-gray-800">Ca

我真的被Bootstrap中的列系统搞糊涂了。以下是我所拥有的:

<div class="container-fluid">

<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4">
  <h1 class="h3 mb-0 text-gray-800">Cards</h1>
</div>

<div class="row">

  <!-- Earnings (Monthly) Card Example -->
  <div class="col-xl-2 col-md-2 mb-2">
    <div class="card border-left-primary shadow h-100 py-2">
      <div class="card-body">
        <div class="row no-gutters align-items-center">
          <div class="col mr-2">
            <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Stop</div>
            <div class="h5 mb-0 font-weight-bold text-gray-800">8</div>
          </div>
          <div class="col-auto">
            <span class="material-icons">
              pan_tool
              </span>
             
          </div>
        </div>
      </div>
    </div>
  </div>

卡
停止
8.
盘形工具
我一共有8张牌,其中2张因为间距的原因落在第二行。我怎样才能用我的卡片获得专业的视角?我需要显示12种不同的机器状态,启动、停止和运行

以下是JSFIDLE的链接:

您只需为所有要使其相等的div元素设置类'col'。如下所示:-

这是否回答了您的问题?请澄清,标题“一行8项…”似乎与问题的代码和描述不匹配。代码中的12张卡在哪里?“[…]我有8张卡,其中2张在第二行”-从数学角度看;每行可以容纳12列。由于每张卡占用2列(
col-2
),因此总共有16列。6张卡片将放入一行(6张卡片*2列为12列),因此剩余的4列(2张卡片*2列)将被推到第二行。您的解决方案必须是
col-1
而不是
col-2
,或者不为您的每张卡使用
col-*
类并使用不同的方法(例如flexbox)