Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center align content in Angular material is not working

I'm using Angular 8 and Angular Material for layout.

I have a card with progress spinner

<mat-card>
  <mat-card-content class="text-center">
    <mat-progress-spinner class="text-center"
      [color]="color"
      [mode]="mode">
    </mat-progress-spinner>
  </mat-card-content>
</mat-card>

enter image description here

It is aligned on the left. I want to align center.

I tried adding text-center with CSS

.text-center {
  text-align: center;
}

But this does not work. Isn't there any predefined class for aligning content in the Angular Material?

I found one on Google search: https://material.angularjs.org/latest/layout/alignment, But this is form Angularjs version.

like image 639
Anuj TBE Avatar asked Nov 30 '25 22:11

Anuj TBE


1 Answers

You can do it whit flex, adding this css in your component:

mat-card-content {
    justify-content: center;
    display: flex;
}
like image 95
Juan Daniel Ornella Avatar answered Dec 02 '25 12:12

Juan Daniel Ornella



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!