0

I am trying to create a header that contains a title that should be center aligned and some buttons that should be on the left. I'm trying to use flexbox and the align-self property but I can't get it to work.

Below is the code snippet:

  <div class="container">
    <span>
      <button pButton type="button" class="btn" icon="fa fa-check" iconPos="left" (click)="save()" label="Save"></button>
      <button pButton type="button" class="btn" (click)="fileInput.click()" label="Load file"></button>
      <input hidden type="file" #fileInput accept=".json" (change)="loadFile($event)" />
      <button pButton type="button" class="btn ui-button-success" iconPos="left" (click)="lockPage = !lockPage"
        [icon]="lockPage ? 'fa fa-unlock' : 'fa fa-lock'"></button>
    </span>
    <span style="align-self: center">
      <input type="text" class="name" pInputText [(ngModel)]="model.name" (keydown.enter)="$event.target.blur()" />
    </span>
  </div>

and the css:

.container {
    display: flex;
    justify-content: flex-start;
}

However the align-self property doesn't work (the way I expect it to...) and the end result is this:

enter image description here

So what am I doing wrong and what is the proper way to get the title in the center of the parent container?

Haritos30
  • 200
  • 2
  • 9

1 Answers1

1

Instead of align-self: auto you can use

margin: 0 auto;
protestator
  • 311
  • 1
  • 15