Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bootstrap 5 Content in Card header float left and right not working

I have a card made using Bootstrap 5.

Basically I’m trying to get a title on the left of the card header and a group of buttons on the right of the card header so this is what I’ve done:

<div class="card-header">
  <div class="float-start">
    <h3>title</h3>
  </div>
  <div class="float-end">
    <button class="btn btn-primary">Add</button>
    <button class="btn btn-primary">Edit</button>
  </div>
  </div>

For some reason the title and buttons are not in the header.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How do I do this properly using Bootstrap 5?

>Solution :

All card-* classes need a direct parent card class to work properly. Change your code to:

<div class="card">
  <div class="card-header">
    <div class="float-start">
      <h3>title</h3>
    </div>
    <div class="float-end">
      <button class="btn btn-primary">Add</button>
      <button class="btn btn-primary">Edit</button>
    </div>
  </div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading