像一组一样创建Bootstrap 4卡网格的容器

要为Bootstrap卡设置容器并将其设置为组,请使用card-group类。

使用它并使用两个Bootstrap卡创建如下所示的网格-

<div class="card-group">
  <div class="card bg-primary">
    <div class="card-body text-center">
      <p class="card-text">Demo Text!</p>
    </div>
   </div>
   <div class="card bg-warning">
     <div class="card-body text-center text-white">
       <p class="card-text">Warning!</p>
     </div>
   </div>
</div>

以下是在Bootstrap中创建网格(卡组)的示例-

示例

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>
<body>
  <div class="container">
    <h3>Group of Messages</h3>
    <div class="card-group">
      <div class="card bg-primary">
        <div class="card-body text-center">
          <p class="card-text">Demo Text!</p>
        </div>
      </div>
      <div class="card bg-warning">
        <div class="card-body text-center text-white">
          <p class="card-text">Warning!</p>
        </div>
      </div>
      <div class="card bg-success">
        <div class="card-body text-center">
           <p class="card-text">Well done!</p>
        </div>
      </div>
      <div class="card bg-success">
        <div class="card-body text-center">
          <p class="card-text">Selected!</p>
        </div>
      </div>
     </div>
   </div>
</body>
</html>