2

I have a small problem with a card body, I want to have both column in center, as you can see in the picture, it's kinda on the left compare to the button... I have tried some class in bootstrap but I can't seem to find the right one... Hope you can help me [EDIT AFTER isherwood]

So I have tried putting text-center but I don't know why it's not working the same ways as the snippet...

<div class="card">
          <div class="card-body ">
            <h5 class="card-title text-center">Jours</h5>
            <div>
              <div class="d-flex justify-content-center">
                <div class="col-sm-6 mb-3 text-center">
                  <fa-icon class="h5" [icon]="faFont.faCoffee"></fa-icon> Matin
                  <div *ngFor="let jour of semaine" class="ms-3 form-check">
                    <input class="form-check-input" type="checkbox" [value]="jour">
                    <label class="form-check-label d-inline-flex">{{jour}}</label>
                  </div>
                </div>
                <div class=" col-sm-6 mb-3 text-center">
                  <fa-icon class="h5" [icon]="faFont.faCookieBite"></fa-icon> Après-Midi
                  <div *ngFor="let jour of semaine" class="ms-3 form-check">
                    <input class="form-check-input" type="checkbox" [value]="jour">
                    <label class="form-check-label d-inline-flex">{{jour}}</label>
                  </div>
                </div>
              </div>
            </div>

            <div class="text-center">
              <button type="button" class="btn btn-primary">Valider</button>
            </div>
          </div>
snsdtiti
  • 35
  • 6

1 Answers1

1

If I understand correctly, just include text-center on each column:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">

<div class="card">
  <div class="card-body ">
    <h5 class="card-title text-center">Jours</h5>
    <div>
      <div class="d-flex justify-content-center">
        <div class="col-sm-6 mb-3 text-center">
          <fa-icon class="h5" [icon]="faFont.faCoffee"></fa-icon> Matin
          <div *ngFor="let jour of semaine" class="ms-3 form-check">
            <input class="form-check-input" type="checkbox" [value]="jour">
            <label class="form-check-label d-inline-flex">{{jour}}</label>
          </div>
        </div>
        <div class=" col-sm-6 mb-3 text-center">
          <fa-icon class="h5" [icon]="faFont.faCookieBite"></fa-icon> Après-Midi
          <div *ngFor="let jour of semaine" class="ms-3 form-check">
            <input class="form-check-input" type="checkbox" [value]="jour">
            <label class="form-check-label d-inline-flex">{{jour}}</label>
          </div>
        </div>
      </div>
    </div>

    <div class="text-center">
      <button type="button" class="btn btn-primary">Valider</button>
    </div>
  </div>
</div>

https://getbootstrap.com/docs/4.5/utilities/text/#text-alignment

isherwood
  • 58,414
  • 16
  • 114
  • 157
  • Thank you but it's not working like the snippet... I have the text in the center but not in straight vertical and the checkbox are still in the same place... – snsdtiti May 19 '21 at 21:45
  • I can't help with what I can't see. You took the working snippet out of your answer. Maybe we can figure it out if you restore that and get it to show the problem. – isherwood May 20 '21 at 12:33