0

I have created the following card layout (shown in the screenshot) using bootstrap. The .card-columns class is adding my cards vertically so that I am loosing some part of the card.

I want my cards aligned horizontally and exactly 3 cards per row without changing the size of the card.

Here is my markup and code:

<body>
  <div class="card-columns">
  <?php
      $conn=new mysqli("localhost","root","","dbname");
          if(!$conn)
          {
            echo "connection_failed";
          }
          else{

          }
          $query= "select title,description,id from problems where difficulty='hard'";
          $result=mysqli_query($conn,$query);
          $num=mysqli_num_rows($result);
          if(mysqli_query($conn,$query)){

          }
          else{
        echo "Error: " . $query . "<br>" . mysqli_error($conn);
      }
        ?>

<?php 
  while ($row=mysqli_fetch_array($result)) { 
    $title=$row[0];
    $description=$row[1];
    $index=$row[2];
    ?>
    <div class="card-group">
  <div class="card bg-info">
    <div class="card-body">
      <h5 class="card-title" style="color:white;">Card title</h5>
      <p class="card-text" style="color: white;">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
    </div>
  </div>
</div>
</body>
<?php }?>

8
  • Welcome to Stack Overflow! Questions seeking code help must include the shortest code necessary to reproduce it in the question itself preferably in a Stack Snippet. See How to create a Minimal, Reproducible Example
    – Paulie_D
    Commented Apr 28, 2020 at 14:25
  • ..but it seems to me you don't want columns, you want rows
    – Paulie_D
    Commented Apr 28, 2020 at 14:25
  • yes i want rows. that's what i am asking for Commented Apr 28, 2020 at 14:38
  • That's why we need the demo...in BS4 the cards will all be the same height be default. From the picture it does not look like you have arranged in rows but are actually using columns.
    – Paulie_D
    Commented Apr 28, 2020 at 14:53
  • i don't know what went wrong please look at it and arrange it in rows please Commented Apr 28, 2020 at 14:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.