Container to create a grid of Bootstrap 4 cards like a group

BootstrapWeb DevelopmentCSS Framework

To set a container for Bootstrap card and set it like a group, use the card-group class.

Use it and create a grid like the following with two Bootstrap cards:

<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>

The following is an example to create a grid (group of cards) in Bootstrap:

Live Demo

<!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://ajax.googleapis.com/ajax/libs/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>
raja
Published on 21-Jul-2018 11:38:51
Advertisements