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

Align 2 buttons to the right of text

I am trying to make my two buttons appear on the far right of a piece of text. I want the text and two buttons to all be inline with each other but the text is on the left and the two buttons are on the right. I have seen multiple solutions and I could get it to work with only 1 button but when I have two buttons it does not work.

I run a for loop over ‘weaknesses’ and print out each weakness. Each weakness will have an update and delete action.

I tried to do margin-left but each weakness is a different length so my buttons would not line up

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

I also tried using some solutions from this post but could not seem to get the expected outcome: Place a button right aligned

Any help would be appreciated

HTML

<div *ngFor="let weakness of weaknesses | async">
    <div class="flex-box">
        <p>{{ weakness }}</p>
        <a class="btn btn-light btn-sm pull-right" href="#">Update</a>
        <button type="button" class="btn btn-danger btn-sm">Delete</button>
    </div>
</div>

>Solution :

One solution is auto margin with flex

nav {
  display: flex;
  align-items: center;
}

nav button:first-of-type {
  /* Key here is margin-left needs to be auto */
  margin: 0 10px 0 auto
}
<nav>
  <span>Text</span>
  <button>Button 1</button>
  <button>Button 2</button>
</nav>
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