Bootstrap 4 - card overflow in small screen

Viewed 1227

in my application, I use a lot the bootcard .card class.

Only, very often when I switch to mobile view, I notice a big overflow, which causes a display bug, and my whole page is found shifted.

Which means that I have to change the code in my .card class each time to make sure everything fits even in mobile view. It's very weird

On large screen :

enter image description here

On small screen :

enter image description here

This is the code :

<div class="card mt-4">
    <h5 class="card-header">
        Abonnement
        <div class="float-right">
            <button class="btn btn-light btn-sm mb-1">Ne pas résilier l'abonnement</button>
        </div>
    </h5>
    <div class="card-body">
        <table class="table table-borderless">
            <thead>
                <tr>
                    <th>PRODUIT</th>
                    <th>PROCHAINE FACTURE</th>
                    <th>CRÉÉ LE</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>
                        TETETE
                        <span class="badge badge-secondary">Annulation prévue 03/05/2020</span>
                        <br>
                        <p class="text-secondary">
                            basic
                        </p>
                    </td>
                    <td>
                        Pas de prochaine facture
                    </td>
                    <td>
                        03/04/2020
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

Thanks for your help !

2 Answers

If it possible replace the table with columns.

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
  <div class="card mt-4">
    <h5 class="card-header">
      Abonnement
      <button class="btn btn-light btn-sm mb-1 float-sm-right">Ne pas résilier l'abonnement</button>
    </h5>
    <div class="card-body">
      <div class="row">
        <div class="col-12 col-sm-4">
          <h5>PRODUIT</h5>
          TETETE
          <span class="badge badge-secondary">Annulation prévue 03/05/2020</span>
          <p class="text-secondary">
            basic
          </p>
        </div>
        <div class="col-12 col-sm-4">
          <h5>PROCHAINE FACTURE</h5>
          <p class="text-secondary">
            Pas de prochaine facture
          </p>
        </div>
        <div class="col-12 col-sm-4">
          <h5>CRÉÉ LE</h5>
          <p class="text-secondary">
            03/04/2020
          </p>
        </div>
      </div>
    </div>
  </div>
</div>

Add class table-responsive to the table:

body{ width: 360px; } /* Galaxy S */
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="card mt-4">
    <h5 class="card-header">
        Abonnement
        <div class="float-right">
            <button class="btn btn-light btn-sm mb-1">Ne pas résilier l'abonnement</button>
        </div>
    </h5>
    <div class="card-body">
        <table class="table table-borderless table-responsive">
            <thead>
                <tr>
                    <th>PRODUIT</th>
                    <th>PROCHAINE FACTURE</th>
                    <th>CRÉÉ LE</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>
                        TETETE
                        <span class="badge badge-secondary">Annulation prévue 03/05/2020</span>
                        <br>
                        <p class="text-secondary">
                            basic
                        </p>
                    </td>
                    <td>
                        Pas de prochaine facture
                    </td>
                    <td>
                        03/04/2020
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

Related